getgrav / getgrav/grav-plugin-admin

Duplicate URL

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

Description

# Introduction

The Grav uses sorting prefixes for folders (Folder Numeric Prefix) that make up the structure of the site at a specific level (Parent).

E.g. for /root:
```
/01.home
/02.about-us
/03.services
/04.contact
/other
```

When the Grav creating a URL, the prefix ignores and the URL of the `/03.services` is then `http(s)://www.sitedomain.tld/services`. Which is fine.

If a user wants to create a page with the same name (Folder Name) on the same level (Parent) over the Plugin Admin Panel, the Grav ignores it and redirects the user instead to edit an existing page (with the same Folder Name). Which is also fine.

# Problem

When sorting prefixes (Folder Numeric Prefix) are used, the Grav when shifting pages in the administration (through the Admin Panel plugin) does not check the match of the existing pages name, respectively folders name and create duplicates.

For example, there may be more pages named "Example" within one (Parent) level:
```
/01.example
/02.example
/example
```

All listed pages have URL `http(s)://www.sitedomain.tld/example`, which is a problem. The Grav will display e.g. `/01.example` on the specified URL, others will be ignored.

The problem is with administration (via the Admin Panel plugin) too. Because only the page that the Grav favors can be edited (because they all have the same URL `/admin/pages/home/example`). There is a big risk even when the page is removed, because the Grav simply chooses.

> Note: I did not look at what the Grav determines which page is prefers.

A similar problem is when user rename a Folder Name within a specific Parent folder.

# Solution

The Grav will check the page/folder names when moving/renaming if they are used in the target Folder Numeric Prefix, and if the same folder name exists, then let the user one of the following (or hard insert to the system):

1. notify the user that there is a folder with the same name in the destination parent folder and telling him to rename the moved folder first and then to move it,
2. notify the user that there is a folder with the same name in the destination parent folder and telling him that the moved folder will be renamed (e.g. `contact` => `contact-1`), ideally with the option of selecting a folder name by user,
3. notify the user that there is a folder with the same name in the destination parent folder and telling him that the Grav replace it with a prior consent (potential risk of data overwriting).

# Risk

This can only be resolved at the Admin Panel plugin level, but it can't be avoided by directly editing a structure such as an FTP client, however, in this case, it can be assumed that the more advanced users are overseeing them.

> Tags: Admin Panel plugin, duplicate, URL, bug, rename, move, folder, name

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.