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 | 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 else
s 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)
Change History (17)
#5
@
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
@
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.
#8
@
11 years ago
- Keywords 3.7-early removed
- Milestone changed from 3.7 to 3.8
Let's make sure ryan looks this over.
#10
@
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.
#13
@
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
@
11 years ago
This is probably going to miss 3.9 unless we can get some testing and tests in here.
Curiously, not a regression — existed back when this was just a wp_cache_init() call too.