getgrav / getgrav/grav-plugin-api
Copying a page duplicates routes.default, so both pages claim the same address
- Dominant language
- PHP
- Stars
- 5
- Forks
- 8
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 2
Description
Split out of #25 / #26, where it was raised by @Gleydar.
`Folder::copy()` reproduces a page's frontmatter byte for byte. #25 fixed the `slug:` half of that: a copied page now gets its own slug so it stops claiming the source's address.
`routes.default` clashes in exactly the same way and is not covered:
```yaml
---
title: Test
routes:
default: /a-fixed-address
---
```
`Page::route()` short-circuits to `$this->routes['default']` when it is set, so the copy answers to the same address as the source regardless of its folder or its slug. `Pages::buildRoutes()` also registers `routes.aliases` into the same map, so aliases can collide too.
Not fixed alongside the slug because the right behaviour is less obvious. Deleting the whole `routes` block (which the original PR proposed) also throws away `aliases` and `canonical`, and silently dropping something an author typed is worse than the clash. Admin-classic copies `routes` verbatim too, so this is long-standing rather than a regression.
Worth deciding whether a copy should drop `routes.default` only, blank it, or leave it and let the admin warn. Low urgency now that the admin page views key on the structural route (getgrav/grav-plugin-admin2#154), so a duplicate address no longer blanks the listing.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with Folder::copy(), then trace Page::route() and Pages::buildRoutes() to understand how default routes and aliases are copied and registered. Compare the existing slug-copy behavior with the routes frontmatter cases described here. Done means the project has an agreed copy policy for routes.default and aliases, with duplicate-address behavior covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100