Skip to content

Duplicate page created after editing when using 3-digits (< 100) prefix #2492

@pmetras

Description

@pmetras

Context

I'm migrating a site with hundreds of pages from Pico CMS. I've written a script to move files from Pico's structure to Grav's one, using 3-digits folder prefix. When editing some pages, a duplicate page is created in a 2 digits-prefix folder with the same name.

How to reproduce the problem

Here is the minimal setup to reproduce the case:

  1. Download Grav+Admin: wget https://getgrav.org/download/core/grav-admin/1.7.49.5 and install it. I can't use the latest version https://getgrav.org/download/core/grav-admin/latest as it requires PHP version > 8.3 and my server uses PHP 8.2.29. Update the plugins to the latest versions (Image).
  2. From the command line, create a page with a 3-digits prefix:
$ pwd
/var/www/grav/user/pages
$ mkdir 005.test
$ cp 01.home/default.md 005.test/
  1. Go to edit the test pages. Before:
Image
  1. In the editor, the page directory is correct:
Image
  1. Save the page:
Image

After the save, you can see that the directory of the page has changed, from 005.test to 05.test.

How to fix it

The bug occurs only for pages with prefixes in the range 000 to 099, or 0 to 9.

One could say that this is desired and that the user must always use fixed-length 2-digits prefix. This rule is probably too strict as I have hundreds of pages.

The best way would probably be to have a prefix_pattern in the site.yaml config file where one can define what the ordering pattern is: prefix_pattern: DDD.

Mentions

Already mentioned in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions