getgrav / getgrav/grav-plugin-admin

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

Open
#2,492 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

## 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/
```

3. Go to edit the `test` pages. Before:

Image

4. In the editor, the page directory is correct:

Image

5. 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

* https://github.com/getgrav/grav-plugin-admin/issues/2257
* https://discourse.getgrav.org/t/page-edit-problems/27886

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.