WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12065 closed defect (bug) (fixed)

Clean up cache re-init code in Multisite

Reported by: nacin Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: Multisite Keywords: has-patch
Focuses: Cc:

Description

During MS load we initialize the object cache again.

wp_cache_init(); // need to init cache again after blog_id is set

if ( function_exists('wp_cache_add_global_groups') ) { // need to add these again. Yes, it's an ugly hack
	wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
	wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
}

Assuming re-initialization indeed needs to occur (a comment says we need to after blog_id is set), we can clean this up now that we have wp_start_object_cache() in wp-includes/load.php.

It is also missing the site-transients group, so that will fix this.

Hypothetically, we could replace that with wp_start_object_cache() and be done with it, but to save CPU cycles and an unnecessary filesystem check, we should modify wp_start_object_cache() while we're at it.

We can either split the function into two, or first check if wp_cache_init() exists before setting $_wp_using_ext_object_cache, checking for the object-cache.php drop-in, and including either wp-content/object-cache.php or wp-includes/cache.php.

Patch attached with one of these options.

Attachments (1)

12065.diff (1.9 KB) - added by nacin 4 years ago.

Download all attachments as: .zip

Change History (3)

nacin4 years ago

comment:1 nacin4 years ago

  • Keywords has-patch added

comment:2 ryan4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12888]) Clean up cache re-init code in Multisite. Props nacin. fixes #12065

Note: See TracTickets for help on using tickets.