statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.03k stars 530 forks source link

Updating term slug does not update references in entries #11021

Closed daun closed 4 days ago

daun commented 4 days ago

Bug description

When changing a term's slug, it should in theory update any references to that term across all entries. That's what the UpdateTermReferences subscriber looks to be doing, but it never happens.

The reason seems to be that $term->getOriginal('slug') always returns null and no listener can relate old to new slug on a term to do the updating. Unfortunately, this also makes it impossible to fix in user land.

This issue is related to #10938 but not quite the same issue, as the other one can be solved with a custom event listener and this one can't, at least not without touching vendor files.

How to reproduce

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.29.0
PHP Version: 8.3.3
Composer Version: 2.5.1
Environment: local
Debug Mode: ENABLED
URL: statamic-terms-test.test
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

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


### Installation

Fresh statamic/statamic site via CLI

### Additional details

_No response_
duncanmcclean commented 4 days ago

This is the same root cause as #10938. To keep things tidy, I'm going to close this in favour of that one.

daun commented 4 days ago

@duncanmcclean Alright. I'd have preferred to close the other one, which is not that big a deal since an event listener can solve it in production. This one here will permanently break references in entries and practically prevents cp users from editing existing terms.