Skip to content

[5.x] Fix term reference updates after slug change - #11058

Merged
jasonvarga merged 1 commit into
statamic:5.xfrom
daun:fix/term-dirty-state
Nov 5, 2025
Merged

jasonvarga merged 1 commit into
statamic:5.xfrom
daun:fix/term-dirty-state

Conversation

@daun

@daun daun commented Nov 5, 2024

Copy link
Copy Markdown
Contributor

Fix an issue where updating a term's slug through the control panel would not update the references to that term in existing entries, even though system.update_references is enabled.

The root of the issue appears to be that the auto-bound Term instance in the CP controller lacks its original data because there is no initial syncOriginal() call. The first call to syncOriginal happens only after saving, which is not helpful here. I’m not sure why this doesn't also happen with Entries, but it seems to work there.

The existing tests haven't caught this as it only happens in the CP controller, not when creating and updating terms in a test environment. Would love to contribute tests here as well, but that's a bit over my head how to test this reliably across the CP routes/controllers.

Closes #10938

Related: #11021

@daun

daun commented Nov 19, 2024

Copy link
Copy Markdown
Contributor Author

I've just switched a production site from flat-file to eloquent — the suggested fix in this PR is only required for flat-file data. Terms saved in eloquent seem to trigger a reference update as intended. The good news is that it also doesn't hurt :)

@jasonvarga

Copy link
Copy Markdown
Member

I wish I had a more consistent way to reproduce this.

I saw it happen once, then couldn't figure out how to do it again.

I think the issue is that there's a certain situation where a term doesn't have syncOriginal applied to it. I'd rather find that path and address it properly than throw a method on a seemingly random spot.

If you can provide a repo with this reproducible that'll be amazing.

@jasonvarga jasonvarga closed this Dec 19, 2024
@daun

daun commented Dec 19, 2024

Copy link
Copy Markdown
Contributor Author

@jasonvarga Strange. I can reproduce this on every save on three production sites and on a vanilla install, locally and on a VPS. Not sure what I‘m doing wrong to reliably trigger this. I‘ll create a vanilla install and share the repo here :)

@daun

daun commented Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

@jasonvarga I've uploaded a reproduction that reliably shows the issue at daun/statamic-term-update-repro. It's a vanilla install with the default pages collection and a tags taxonomy. The step required for triggering the issue is updating the term's slug. Let me know if you're seeing the issue there.

@jonathan-bird

Copy link
Copy Markdown

@jasonvarga Now we have an ability to reproduce the issue, can we please re-open this issue?

As described here and #11264

@duncanmcclean duncanmcclean reopened this Jan 20, 2025
@daun

daun commented Jan 20, 2025

Copy link
Copy Markdown
Contributor Author

@jonathan-bird Does this PR reliably solve the issue you're seeing in #11264?

@jonathan-bird

Copy link
Copy Markdown

@daun Not sure. I can't reliability replicate the issue with my client's site and I had to manually fix theirs as per my Github issue.

@jasonvarga
jasonvarga merged commit ff8db53 into statamic:5.x Nov 5, 2025
@daun
daun deleted the fix/term-dirty-state branch November 8, 2025 17:46
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.

Updating term slug creates duplicate instead of updating

4 participants