Skip to content

Old slug not removed from static cache when changing slugs #14876

Description

@indykoning

Bug description

When changing the slug on a statamic entry the old html file does not get removed from the file system and remains in cache.
This causes the redirect from the old page to not function and still show the page before the slug change.

How to reproduce

  1. Enable fullpage static cache
  2. Create a new page entry with e.g. the name test
  3. Save the page, visit the page and ensure the .html file is created.
  4. Rename the slug to test2
  5. Save the page, visit the page and ensure the .html file is created.
    To verify the bug:
  6. Try to visit the old test slug page, see if it redirects. Which it won't if the bug exists
  7. Check if the test_.html file exists. Which it will if the bug exists.

Logs

Environment

Environment
Laravel Version: 13.13.0
PHP Version: 8.4.22
Composer Version: 2.10.1
Environment: production
Debug Mode: OFF
Maintenance Mode: OFF
Timezone: UTC
Locale: nl

Cache
Config: NOT CACHED
Events: CACHED
Routes: CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: daily
Mail: smtp
Queue: sync
Session: file

Storage
public/storage: LINKED

Statamic
Stache Watcher: Disabled (auto)
Static Caching: full
Version: 6.20.1 PRO

Statamic Addons
just-better/statamic-authentik: 2.0.0
justbetter/statamic-cloudflare-purge: 2.0.0
justbetter/statamic-detour: 0.5.0
justbetter/statamic-download-center: dev-master
justbetter/statamic-glide-directive: 4.1.0
justbetter/statamic-image-optimize: 5.2.0
justbetter/statamic-veto: 0.3.0
statamic-rad-pack/runway: 9.4.5
statamic/eloquent-driver: 5.9.0
tdwesten/statamic-builder: 3.0.9

Statamic Eloquent Driver
Addon Settings: file
Asset Containers: file
Assets: eloquent
Blueprints: file
Collection Trees: eloquent
Collections: file
Entries: eloquent
Fieldsets: file
Form Submissions: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: file
Revisions: file
Sites: file
Taxonomies: file
Terms: eloquent
Tokens: eloquent

Installation

Existing Laravel app

Additional details

Perhaps we need a dedicated save observer checking for slug changes, and passing the old slug to the invalidator instead of the usual method of passing the current slug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions