Make WordPress Core

Ticket #23290: 23290.patch

File 23290.patch, 4.6 KB (added by ethitter, 12 years ago)
  • wp-includes/cache.php

     
    608608        }
    609609
    610610        /**
     611         * Retrieve array of non-persistent cache groups
     612         *
     613         * @since 3.6.0
     614         *
     615         * @return array
     616         */
     617        function get_non_persistent_groups() {
     618                $all_groups = array_keys( $this->cache );
     619                $all_groups = array_fill_keys( $all_groups, true );
     620
     621                $non_persistent_groups = array_diff_key( $all_groups, $this->global_groups );
     622
     623                return $non_persistent_groups;
     624        }
     625
     626        /**
    611627         * Utility function to determine whether a key exists in the cache.
    612628         *
    613629         * @since 3.4.0
  • wp-includes/ms-blogs.php

     
    518518        $prev_blog_id = $GLOBALS['blog_id'];
    519519        $GLOBALS['blog_id'] = $new_blog;
    520520
    521         if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
     521        if ( function_exists( 'wp_cache_switch_to_blog' ) )
    522522                wp_cache_switch_to_blog( $new_blog );
    523         } else {
    524                 global $wp_object_cache;
     523        else
     524                _ms_cache_switch_fallback();
    525525
    526                 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
    527                         $global_groups = $wp_object_cache->global_groups;
    528                 else
    529                         $global_groups = false;
    530 
    531                 wp_cache_init();
    532 
    533                 if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    534                         if ( is_array( $global_groups ) )
    535                                 wp_cache_add_global_groups( $global_groups );
    536                         else
    537                                 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
    538                         wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
    539                 }
    540         }
    541 
    542526        if ( did_action( 'init' ) ) {
    543527                $wp_roles->reinit();
    544528                $current_user = wp_get_current_user();
     
    579563        $GLOBALS['blog_id'] = $blog;
    580564        $GLOBALS['table_prefix'] = $wpdb->prefix;
    581565
    582         if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
     566        if ( function_exists( 'wp_cache_switch_to_blog' ) )
    583567                wp_cache_switch_to_blog( $blog );
    584         } else {
    585                 global $wp_object_cache;
     568        else
     569                _ms_cache_switch_fallback();
    586570
    587                 if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
    588                         $global_groups = $wp_object_cache->global_groups;
    589                 else
    590                         $global_groups = false;
    591 
    592                 wp_cache_init();
    593 
    594                 if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    595                         if ( is_array( $global_groups ) )
    596                                 wp_cache_add_global_groups( $global_groups );
    597                         else
    598                                 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
    599                         wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
    600                 }
    601         }
    602 
    603571        if ( did_action( 'init' ) ) {
    604572                $wp_roles->reinit();
    605573                $current_user = wp_get_current_user();
     
    626594}
    627595
    628596/**
     597 * Cache reset process used when switch_to_blog() and restore_current_blog() are called.
     598 * Necessary only when persistent object cache doesn't have a wp_cache_switch_to_blog() function.
     599 *
     600 * @since 3.6.0
     601 *
     602 * @global $wp_object_cache
     603 *
     604 * @uses _wp_cache_get_all_nonpersistent_groups
     605 * @uses wp_cache_init
     606 * @uses wp_cache_add_global_groups
     607 * @uses wp_cache_add_nonpersistent_groups
     608 * @return null
     609 */
     610function _ms_cache_switch_fallback() {
     611        global $wp_object_cache;
     612
     613        if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
     614                $global_groups = $wp_object_cache->global_groups;
     615        else
     616                $global_groups = false;
     617
     618        if ( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'get_non_persistent_groups' ) )
     619                $non_persistent_groups = $wp_object_cache->get_non_persistent_groups();
     620        else
     621                $non_persistent_groups = false;
     622
     623        wp_cache_init();
     624
     625        if ( function_exists( 'wp_cache_add_global_groups' ) ) {
     626                if ( is_array( $global_groups ) )
     627                        wp_cache_add_global_groups( $global_groups );
     628                else
     629                        wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
     630        }
     631
     632        if ( function_exists( 'wp_cache_add_non_persistent_groups' ) ) {
     633                if ( is_array( $non_persistent_groups ) )
     634                        wp_cache_add_non_persistent_groups( $non_persistent_groups );
     635                else
     636                        wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
     637        }
     638}
     639
     640/**
    629641 * Check if a particular blog is archived.
    630642 *
    631643 * @since MU