Skip to content

fix: clear legacy cache variants for one URL - #1105

Draft
Atroci wants to merge 1 commit into
Automattic:trunkfrom
Atroci:fix-delete-legacy-wp-cache
Draft

fix: clear legacy cache variants for one URL#1105
Atroci wants to merge 1 commit into
Automattic:trunkfrom
Atroci:fix-delete-legacy-wp-cache

Conversation

@Atroci

@Atroci Atroci commented Aug 27, 2026

Copy link
Copy Markdown

Fixes #1086

Why

The admin-bar Delete Cache action clears the page's supercache directory but leaves legacy wp-cache files for the same URL. Query-string requests expose the gap because they are served by those legacy files, so a URL such as /some-post/?utm_source=test remains stale after deletion.

What Changed

  • Keep nonce verification tied to the complete posted URI, then derive its normalized path for invalidation.
  • Scan only the current $blog_cache_dir metadata and delete cache pairs whose URI has the same path, regardless of query string.
  • Support current .php/JSON pairs and pre-2015 .html/serialized .meta pairs.
  • Preserve child and sibling paths, malformed metadata, other multisite cache directories, and the separate whole-site deletion branch.

Verification

  • Regression coverage removes bare, UTM, gclid, fbclid, functional-query, gzip-key, and historical HTML variants for one path.
  • Coverage preserves child paths, sibling paths, malformed metadata, cache files outside the configured cache root, and another blog's cache directory.
  • The real WordPress integration test posts a query-string path through capability and nonce checks, removes immediate HTML/gzip/wp-cache files, and preserves a child directory.
  • PHPCS passes.
  • Smoke suite: 85 tests, 134 assertions.
  • Integration suite: 53 tests, 152 assertions in both single-site and multisite modes.

Release Notes

Fixed the Delete Cache action so it clears legacy wp-cache representations for the selected URL, including query-string variants, without recursively clearing child URLs.

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.

Delete Cache button does not clear the legacy wp-cache files for the URL

1 participant