Skip to content

Commit 88024e6

Browse files
committed
Clean up cache re-init code in Multisite. Props nacin. fixes WordPress#12065
git-svn-id: https://develop.svn.wordpress.org/trunk@12888 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8d029ac commit 88024e6

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

wp-includes/load.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,15 @@ function wp_set_wpdb_vars() {
318318
* @since 3.0.0
319319
*/
320320
function wp_start_object_cache() {
321-
global $_wp_using_ext_object_cache;
322-
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
323-
require_once ( WP_CONTENT_DIR . '/object-cache.php' );
324-
$_wp_using_ext_object_cache = true;
325-
} else {
326-
require_once ( ABSPATH . WPINC . '/cache.php' );
327-
$_wp_using_ext_object_cache = false;
321+
if ( ! function_exists( 'wp_cache_init' ) ) {
322+
global $_wp_using_ext_object_cache;
323+
if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
324+
require_once ( WP_CONTENT_DIR . '/object-cache.php' );
325+
$_wp_using_ext_object_cache = true;
326+
} else {
327+
require_once ( ABSPATH . WPINC . '/cache.php' );
328+
$_wp_using_ext_object_cache = false;
329+
}
328330
}
329331

330332
wp_cache_init();

wp-includes/ms-settings.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,8 @@
152152
if ( empty($PHP_SELF) || ( empty($PHP_SELF) && !is_subdomain_install() && $current_blog->path != '/' ) )
153153
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
154154

155-
wp_cache_init(); // need to init cache again after blog_id is set
156-
if ( function_exists('wp_cache_add_global_groups') ) { // need to add these again. Yes, it's an ugly hack
157-
wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
158-
wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
159-
}
155+
// need to init cache again after blog_id is set
156+
wp_start_object_cache();
160157

161158
ms_default_constants( 'uploads' );
162159

0 commit comments

Comments
 (0)