WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/19/2017 04:21:38 PM (3 years ago)
Author:
flixos90
Message:

Multisite: Handle sites cache invalidation more granularly for option updates.

Previously update_blog_option() would trigger an invalidation of that site's entire cache although these changes did not affect the content of these caches. Furthermore changes to the special options blogname, siteurl and post_count should not invalidate the entire cache of that site, but only their respective site details cache. The option home now has the same behavior as it also belongs to the site details, but did not invalidate the cache at all previously.

Several new unit tests confirm these changes work as expected.

Fixes #40063.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-blogs.php

    r39082 r40305  
    471471
    472472    wp_cache_set( 'last_changed', microtime(), 'sites' );
     473}
     474
     475/**
     476 * Cleans the site details cache for a site.
     477 *
     478 * @since 4.7.4
     479 * @private
     480 *
     481 * @param int $site_id Optional. Site ID. Default is the current site ID.
     482 */
     483function _clean_site_details_cache( $site_id = 0 ) {
     484    $site_id = (int) $site_id;
     485    if ( ! $site_id ) {
     486        $site_id = get_current_blog_id();
     487    }
     488
     489    wp_cache_delete( $site_id, 'site-details' );
     490    wp_cache_delete( $site_id, 'blog-details' );
    473491}
    474492
     
    737755    restore_current_blog();
    738756
    739     refresh_blog_details( $id );
    740 
    741757    return $return;
    742758}
Note: See TracChangeset for help on using the changeset viewer.