Opened 5 years ago
Last modified 2 months ago
#55454 new defect (bug)
clean_site_details_cache() doesn't clean all site caches
| Reported by: | dd32 | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | Awaiting Review |
| Component: | Networks and Sites | Version: | 4.7 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: | multisite |
Description
clean_site_details_cache() clear's two caches:
wp_cache_delete( $site_id, 'site-details' ); wp_cache_delete( $site_id, 'blog-details' );
But there's a third used within get_blog_details() that's closely related to those two caches:
if ( $get_all ) {
$details = wp_cache_get( $blog_id . 'short', 'blog-details' );
} else {
$details = wp_cache_get( $blog_id, 'blog-details' );
One could argue that the blog-details caches are not related to the site-details caches, but one would expect that if it clears some of them, that it'll clear all of them.
clean_blog_cache() is a much more comprehensive function though:
wp_cache_delete( $blog_id, 'sites' ); wp_cache_delete( $blog_id, 'site-details' ); wp_cache_delete( $blog_id, 'blog-details' ); wp_cache_delete( $blog_id . 'short', 'blog-details' ); wp_cache_delete( $domain_path_key, 'blog-lookup' ); wp_cache_delete( $domain_path_key, 'blog-id-cache' ); wp_cache_delete( $blog_id, 'blog_meta' );
Change History (3)
This ticket was mentioned in Slack in #core-multisite by realloc. View the logs.
17 months ago
#3
@
2 months ago
clean_site_details_cache() only ever runs when one of four options changes: blogname, siteurl, post_count, home. That is worth keeping in mind, because the two caches it misses are not in the same situation.
The short entry never stores those four values in the first place. It is a plain row from the blogs table, and anything asking it for a blog name is quietly redirected to the site-details cache, which the function does clear. So adding it would make the function tidier and match what get_blog_details() reads, but nothing is actually wrong today.
The lookup-by-domain cache is the real problem. When a site is fetched by domain and path, the four option values are baked into the cached object, and the next lookup hands that object straight back without checking anything. Rename a site and the old name keeps coming back from that path until something else clears the cache.
Fixing that one is slightly more than a one-liner: the cache key is built from domain and path, which the function does not currently have, so it would need to load the site first.
Refs:
- callers
ms-default-filters.php:124-127 shortwritesms-blogs.php:152,:170,:242,ms-site.php:402-406- fallthrough
class-wp-site.php:239-250 blog-lookupwritems-blogs.php:253-256,:275, read:141-144
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
#55455 was marked as a duplicate.