WordPress.org

Make WordPress Core

Changeset 37874


Ignore:
Timestamp:
06/26/2016 02:28:35 PM (3 years ago)
Author:
jeremyfelt
Message:

Multisite: Clear incomplete objects from cache in get_blog_details() when found.

In [37657], the blog_id and site_id properties were changed to private. Any WP_Site objects previously stored in cache with public properties should now be considered invalid. We can detect this by checking for these missing properties and clearing the dirty cache if found.

Props flixos90.
Fixes #36717.

File:
1 edited

Legend:

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

    r37699 r37874  
    184184                unset($details);
    185185            }
     186        } elseif ( ! $details->blog_id || ! $details->site_id ) {
     187            // Clear objects missing critical properties.
     188            wp_cache_delete( $blog_id . $all, 'blog-details' );
     189            unset($details);
    186190        } else {
    187191            return $details;
     
    204208                    unset($details);
    205209                }
     210            } elseif ( ! $details->blog_id || ! $details->site_id ) {
     211                // Clear objects missing critical properties.
     212                wp_cache_delete( $blog_id, 'blog-details' );
     213                unset($details);
    206214            } else {
    207215                return $details;
     
    210218    }
    211219
    212     if ( empty($details) ) {
     220    if ( empty( $details ) || ! $details->blog_id || ! $details->site_id ) {
    213221        $details = WP_Site::get_instance( $blog_id );
    214222        if ( ! $details ) {
Note: See TracChangeset for help on using the changeset viewer.