Skip to content

Duplicate slugs allowed with custom route configuration #14482

@martyf

Description

@martyf

Bug description

When using a more advanced route configuration, duplicate slugs are allowed (i.e. entries at a depth of greater than 1 in an ordered collection can share the same slug).

This leads to only one of the entries being accessible.

How to reproduce

  1. Install Statamic 6
  2. Create a new Collection, and set the Route as {{ if depth > 1 }}{{ parent_uri }}/{{ slug }}{{ else }}manual-mount/{{ slug }}{{ /if }}
  3. Create an Entry (i.e. call it Root) - ✅ saves correctly
  4. Create another Entry with the same slug - ✅ validation kicks in correctly
  5. Create a child to the first Entry, such as "Child" (slug becomes child) - ✅ saves correctly
  6. Create another child entry to the first Entry, make the slug be child - ❌ saves (but validation should prevent this)

This route config is a little odd but is required given the site setup here with the depth 0 unable to be explicitly mounted. It must be nested so has a hardcoded base route with a slug, but for depth > 1, then is on the parent.

Logs

Environment

Environment
Laravel Version: 13.4.0
PHP Version: 8.4.19
Composer Version: 2.9.5
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Storage
public/storage: NOT LINKED

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.12.0 PRO

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

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