Updating term slug creates duplicate instead of updating
Bug description
When the stache watcher is disabled, updating a term slug in the control panel creates a duplicate of the term instead of updating the term's slug. Looking at the content folder, the file is correctly renamed, but the control panel shows both the previous as well as the new version of the term.
There's a workaround — clearing the stache from an event listener after each term save — but that probably shouldn't be necessary. There's a related PR #9260 but since that marked the issue as solved, I figured this might be something else and opened a new issue.
With stache watcher disabled
With stache watcher enabled
How to reproduce
- Disable stache watcher
- Create a taxonomy
- Create a term and save
- Edit the term, update the slug, and save
- Return to listing
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 10.48.22
PHP Version: 8.3.3
Composer Version: 2.5.1
Environment: local
Debug Mode: ENABLED
URL: statamic.test
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED
Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file
Statamic
Addons: 1
Sites: 2 (DE, EN)
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.30.0 PRO
Statamic Addons
daun/statamic-widget-collection-count: 1.2.1
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Issue seems to be that $term->getOriginal('slug') returns null resulting in not deleting the old term because it thinks it's new.
Coincidentally, this seems to prevent the automatic update of term references in entries using that taxonomy.
I've uploaded a reproduction that reliably shows the issue at daun/statamic-term-update-repro.