cms icon indicating copy to clipboard operation
cms copied to clipboard

Updating term slug creates duplicate instead of updating

Open daun opened this issue 1 year ago • 2 comments

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

Screen Recording 2024-10-11 at 13 16 55

With stache watcher enabled

Screen Recording 2024-10-11 at 13 19 31

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

daun avatar Oct 11 '24 11:10 daun

Issue seems to be that $term->getOriginal('slug') returns null resulting in not deleting the old term because it thinks it's new.

joshuablum avatar Oct 14 '24 12:10 joshuablum

Coincidentally, this seems to prevent the automatic update of term references in entries using that taxonomy.

daun avatar Oct 14 '24 12:10 daun

I've uploaded a reproduction that reliably shows the issue at daun/statamic-term-update-repro.

daun avatar Jan 09 '25 22:01 daun