Harden Starter Sites cache against orphaned/stale tiob_sites transients#493
Merged
Conversation
… timestamp Co-authored-by: selul <3330746+selul@users.noreply.github.com>
Co-authored-by: selul <3330746+selul@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Starter Sites library stale cache issue
Harden Starter Sites cache against orphaned/stale Jul 10, 2026
tiob_sites transients
Collaborator
Collaborator
|
🎉 This PR is included in version 1.4.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Starter Sites library caches the demosites API response in the
tiob_sitestransient with only WordPress's timeout-row semantics for freshness. When a DB/transient-cleanup tool (WP Rocket, WP-Optimize, etc.) strips_transient_timeout_tiob_sitesbut leaves_transient_tiob_sites,get_transient()treats the value as non-expiring and serves a stale, partial library indefinitely — unrecoverable by update, reinstall, or cache clears.Implements the two low-risk defenses from the issue (items 1 & 2) in
includes/Sites_Listing.php:fetched_atstamp and validate it on read via a newget_cached_sites()helper, rather than trusting the transient timeout row. Any missing/malformed wrapper (including legacy raw payloads) or an age>= 12hforces a re-fetch.tiob_sites→tiob_sites_<TIOB_VERSION>, so every plugin update reads from a fresh key and self-heals a stuck cache.Adds
tests/sites-listing-test.phpcovering: version-stamped key, fresh fetch stores the wrapped payload, fresh cache served without a remote call, stalefetched_atre-fetches (the orphaned-timeout case), and legacy raw payload re-fetches.Items 3 (a UI "Refresh templates" button) and 4 (surfacing fetch failures via Logger/notice) are intentionally out of scope here as larger cross-boundary changes.