Make WordPress Core

Ticket #40201: 40201.diff

File 40201.diff, 2.3 KB (added by flixos90, 8 years ago)
  • src/wp-includes/ms-blogs.php

     
    258258 * Clear the blog details cache.
    259259 *
    260260 * @since MU (3.0.0)
     261 * @deprecated 4.9.0 Use clean_blog_cache()
     262 * @see clean_blog_cache()
    261263 *
    262264 * @param int $blog_id Optional. Blog ID. Defaults to current blog.
    263265 */
    264266function refresh_blog_details( $blog_id = 0 ) {
     267        _deprecated_function( __FUNCTION__, '4.9.0', 'clean_blog_cache()' );
     268
    265269        $blog_id = (int) $blog_id;
    266270        if ( ! $blog_id ) {
    267271                $blog_id = get_current_blog_id();
    268272        }
    269273
    270         $details = get_site( $blog_id );
    271         if ( ! $details ) {
    272                 // Make sure clean_blog_cache() gets the blog ID
    273                 // when the blog has been previously cached as
    274                 // non-existent.
    275                 $details = (object) array(
    276                         'blog_id' => $blog_id,
    277                         'domain' => null,
    278                         'path' => null
    279                 );
    280         }
    281 
    282         clean_blog_cache( $details );
    283 
    284         /**
    285          * Fires after the blog details cache is cleared.
    286          *
    287          * @since 3.4.0
    288          *
    289          * @param int $blog_id Blog ID.
    290          */
    291         do_action( 'refresh_blog_details', $blog_id );
     274        clean_blog_cache( $blog_id );
    292275}
    293276
    294277/**
     
    445428 *
    446429 * @global bool $_wp_suspend_cache_invalidation
    447430 *
    448  * @param WP_Site $blog The site object to be cleared from cache.
     431 * @param WP_Site|int $blog The site object or ID to be cleared from cache.
    449432 */
    450433function clean_blog_cache( $blog ) {
    451434        global $_wp_suspend_cache_invalidation;
     
    454437                return;
    455438        }
    456439
     440        if ( is_numeric( $blog ) ) {
     441                $blog_id = $blog;
     442                $blog = get_site( $blog_id );
     443                if ( ! $blog ) {
     444                        // Make sure a WP_Site object exists even when the site has been deleted.
     445                        $blog = new WP_Site( (object) array(
     446                                'blog_id' => $blog_id,
     447                                'domain'  => null,
     448                                'path'    => null,
     449                        ) );
     450                }
     451        }
     452
    457453        $blog_id = $blog->blog_id;
    458454        $domain_path_key = md5( $blog->domain . $blog->path );
    459455
     
    478474        do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key );
    479475
    480476        wp_cache_set( 'last_changed', microtime(), 'sites' );
     477
     478        /**
     479         * Fires after the blog details cache is cleared.
     480         *
     481         * @since 3.4.0
     482         * @deprecated 4.9.0 Use clean_site_cache
     483         *
     484         * @param int $blog_id Blog ID.
     485         */
     486        do_action_deprecated( 'refresh_blog_details', array( $blog_id ), '4.9.0', 'clean_site_cache' );
    481487}
    482488
    483489/**