Skip to content

Nested IDs don't get regenerated when parent set is duplicated, resulting in duplicate IDs #8438

Description

@el-schneider

Bug description

When copying a Replicator set, that contains another Replicator field. The nested sets don't receive a new ID after being copied. Resulting in duplicate IDs like shown below. I ran into this with a GraphQL project, where this caused a fair bit of mayhem, as my GraphQL client (and I imagine others too) relies on ID fields for caching.

replicator:
  -
    id: ljrijtj3
    enabled: true
    replicator:
      -
        id: lk058djd
        text_field: 'Some other Text'
  -
    id: lk05a53x
    enabled: true
    replicator:
      -
        id: lk058djd
        text_field: 'Some other Text'

How to reproduce

Nest any fieldtype that receives an ID, like Replicator, Bard, and Grid inside another field of such type and duplicate the parent set in the control panel. The parent set receives a new ID, while the children keep the old ID.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 10.14.1
PHP Version: 8.2.7
Composer Version: 2.5.8
Environment: local
Debug Mode: ENABLED
URL: renaming-issue.test
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.10.1 Solo

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

I wonder if the duplicate ID utility for entries, could be adapted to ensure that there are also no sets with duplicate IDs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions