Repository navigation
Conversation
wp_uninitialize_site() drops a site's tables but left that site's option caches populated. alloptions, notoptions and is_blog_installed therefore kept answering for a site that no longer had any tables, so a deleted site still behaved as installed and switch_to_blog() gave no indication that anything was wrong. Clear those three keys once the site's tables have been dropped, while the function is still switched into the deleted site's context. The whole options group is deliberately not flushed, as on multisite it holds every site's prefixed keys. clean_blog_cache() is left untouched. Per the ticket discussion it is a network level cache cleaner, and site level clearing belongs to the deletion routine. Props rmccue, johnjamesjacoby, jeremyfelt. Fixes #29247.
Cover that wp_delete_site() clears alloptions, notoptions and is_blog_installed for the deleted site, and pin that clean_blog_cache() intentionally leaves the site's option caches alone. Props rmccue, johnjamesjacoby, jeremyfelt. Fixes #29247.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Deleting a site leaves that site's option caches populated.
alloptions,notoptionsandis_blog_installedkeep answering for a site whose tables no longer exist, so a deleted site continues to behave as installed. Aswitch_to_blog()into the deleted site succeeds without any indication that the site is gone, whereas clearing the caches surfaces the expectedTable '..._options' doesn't existerror and makes the failure debuggable.The gap is still live on trunk.
clean_blog_cache()only clears the network level site, blog-details, blog-lookup and blog_meta groups. Theoptionsgroup is per site, and nothing in the deletion path clears it.This clears the three keys in
wp_uninitialize_site()once the site's tables have been dropped, while the function is still switched into the deleted site's context, so the per blog keys are hit directly. The wholeoptionsgroup is deliberately not flushed: on multisite that group holds every site's prefixed option keys, so flushing it would evict the entire network's option cache.clean_blog_cache()is intentionally untouched. As noted in the ticket discussion, it is a network level cache cleaner, and site level clearing belongs to the site deletion routine itself. The second test pins that scope so a later change cannot widen it silently.The
alloptionshalf of the report is the one that reproduces most visibly: an autoloaded option is served straight from that cache, so a stale read survives the deletion of the table it came from.Trac ticket: https://core.trac.wordpress.org/ticket/29247
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Sonnet
Used for: test cases, code review
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.