Make WordPress Core

Opened 12 years ago

Last modified 6 years ago

#23290 new defect (bug)

When using switch_to_blog() with a persistent object cache that lacks wp_cache_switch_to_blog() support, non-persistent groups are not maintained

Reported by: markjaquith's profile markjaquith Owned by:
Milestone: Priority: low
Severity: normal Version: 3.0
Component: Cache API Keywords: has-patch needs-testing needs-unit-tests needs-refresh
Focuses: multisite Cc:

Description

If you're using a persistent object cache that lacks the new wp_cache_switch_to_blog() support, WordPress core elses into a complete cache clobbering branch. It is smart about grabbing the global groups and re-adding those after wp_cache_init() is called, but it doesn't do the same for non-persistent groups. Those are a hardcoded array. So if you call switch_to_blog(), you would lose any custom-added non-persistent groups.

Attachments (1)

23290.patch (4.6 KB) - added by ethitter 12 years ago.

Download all attachments as: .zip

Change History (17)

#1 @johnjamesjacoby
12 years ago

  • Cc johnjamesjacoby added

#2 @nacin
12 years ago

  • Version set to 3.0

Curiously, not a regression — existed back when this was just a wp_cache_init() call too.

#3 @ethitter
12 years ago

  • Cc erick@… added

#4 @stevenkword
12 years ago

  • Cc stevenword@… added

@ethitter
12 years ago

#5 @ethitter
12 years ago

  • Keywords has-patch needs-testing added

@stevenkword and I worked on 23290.patch during the Boston WP Hack Day.

We introduced a get_non_persistent_groups() method in Core's WP_Object_Cache to handle the core use, and to be implemented by authors of object cache drop ins. Initially we tried to include universal support for getting the non-persistent cache groups, but review of the APC Object Caching plugin revealed that the structure of $global_groups can vary between persistent backends.

The switching fallback that was present in switch_to_blog() and restore_current_blog() was abstracted into _ms_cache_switch_fallback() for consistency, and logic to use the persistent group getter closely mirrors the handling of global groups already in those functions.

#6 @nacin
11 years ago

  • Keywords 3.7-early added
  • Milestone changed from 3.6 to Future Release

I like this; let's address it in 3.7.

#7 @wonderboymusic
11 years ago

  • Milestone changed from Future Release to 3.7

these are all marked 3.7-early

#8 @nacin
11 years ago

  • Keywords 3.7-early removed
  • Milestone changed from 3.7 to 3.8

Let's make sure ryan looks this over.

#9 @wonderboymusic
11 years ago

  • Keywords needs-unit-tests added

#10 @nunomorgadinho
11 years ago

Any suggestions on what a unit test for this one should include? Maybe we could even separate it into different unit tests. I'm unsure and would appreciate feedback as I would be interested in working on it.

Last edited 11 years ago by nunomorgadinho (previous) (diff)

#11 @nunomorgadinho
11 years ago

  • Cc nuno.morgadinho@… added

#12 @wonderboymusic
11 years ago

  • Milestone changed from 3.8 to Future Release

No unit tests - no Ryan blessing

#13 @jeremyfelt
11 years ago

  • Focuses multisite added
  • Milestone changed from Future Release to 3.9

We probably have an opportunity to get some unit tests in for this in 3.9.

@nunomorgadinho, if you are still interested in working on this, please feel free. It's probably worth looking at the current code in phpunit/tests/cache.php for examples of testing switch_to_blog(). We would then want to use additional tests for the pieces that this patch touches. Don't hesitate to provide any first attempts or stop in #wordpress-dev to go over approach.

#14 @jeremyfelt
11 years ago

This is probably going to miss 3.9 unless we can get some testing and tests in here.

#15 @nacin
11 years ago

  • Milestone changed from 3.9 to Future Release
  • Priority changed from normal to low

There are a number of Cache API things we'd like to do, so moving this out of 3.9.

It's much, much better for object caches to introduce wp_cache_switch_to_blog(), so this is fairly low priority.

#16 @chriscct7
9 years ago

  • Keywords needs-refresh added
Note: See TracTickets for help on using tickets.