Skip to content

[6.x] Fix duplicate ids being lost when the Stache is cleared and warmed in one process - #15883

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
DanielDarrenJones:fix/6x-duplicates-lost-after-clear
Nov 13, 2026
Merged

jasonvarga merged 1 commit into
statamic:6.xfrom
DanielDarrenJones:fix/6x-duplicates-lost-after-clear

Conversation

@DanielDarrenJones

Copy link
Copy Markdown
Contributor

php please stache:refresh loses the list of duplicate ids every other time it runs.

Stache::clear() forgets the duplicates in the cache but Duplicates keeps the ones it has loaded in memory. When the warm that follows comes across the same duplicate again, track() finds the path already in its list and returns without marking anything as changed, so cache() writes nothing. The cache stays empty until the next clear, which starts from an empty list, sees the duplicate as new, and writes it back.

The effect is that the "Duplicate IDs" item in the Control Panel nav, and the page behind it, come and go: they depend on whether the Stache has been refreshed an odd or an even number of times since the duplicate appeared.

Duplicates::clear() now empties its own list as well.

Reproducing it

On 6.x, with two entries that share an id:

Stache::clear(); Stache::warm();   // in one process, as stache:refresh does

and then, from another process, Stache::duplicates()->all() is empty. Run it again and the duplicate is back. With this change it's there every time.

It doesn't happen if the two steps run in separate processes, or if the application cache is flushed in between and the Stache is kept in the default store.

Tests

A duplicate that is found again after clearing is written back to the cache. Fails without the change.

…one process

Clearing forgot the duplicates in the cache but not the ones in memory. When the warm that followed found the same duplicate again it wasn't new, so nothing was written back, and the list stayed empty until the next clear. Every other stache:refresh lost them.
@jasonvarga
jasonvarga merged commit c1728c3 into statamic:6.x Nov 13, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants