Opened 12 months ago
Closed 9 months ago
#20950 closed defect (bug) (fixed)
wpmu_delete_blog leaves zombie cache objects
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
For example cached objects with keys like current_blog_{$domain}, current_blog_{$domain}, get_id_from_blogname_{$name} will be left to haunt the network even after the blog is deleted.
Symptoms will be not being allowed to create blogs with the same name after it's deleted, blog settings of old blogs creeping into newly created blogs.
Attachments (5)
Change History (20)
comment:1
wonderboymusic
— 9 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.5
wonderboymusic
— 9 months ago
comment:2
nacin
— 9 months ago
Noticing the escaping as well. Are the values escaped on storage, hence the bug report suggesting that all three cache entries are not cleared?
comment:4
wonderboymusic
— 9 months ago
Refreshed
wp_cache_delete( md5( $details->domain . $details->path ) , 'blog-lookup' );
Actually needs to be:
wp_cache_delete( md5( $wpdb->escape( $details->domain ) . $wpdb->escape( $details->path ) ) , 'blog-lookup' );
wonderboymusic
— 9 months ago
comment:5
wonderboymusic
— 9 months ago
Only the md5 is not read directly from the object
comment:6
ryan
— 9 months ago
I think get_blog_details( $blog_id, false ) needs to become get_blog_details( $blog_id, true ) to get the blogname.
comment:7
ryan
— 9 months ago
get_id_from_blogname( )actually expects a path, but you can't pass get_blog_details()->path directly to it because of trailing slash problems.
comment:8
ryan
— 9 months ago
get_id_from_blogname() actually takes an unslashed path rather than a blogname so I updated the variables and phpdoc to use the term slug instead of name.
- Rename $name to $slug for some clarity.
- Strip leading and trailing slashes from the slug in get_id_from_blogname() so get_blog_details()->path could be directly passed
- Delete the get_id_from_blogname cache in refresh_blog_details()
comment:9
ryan
— 9 months ago
Unit tests and a fix to WP_UnitTest_Factory_For_Blog that prepends global $base to the path when creating blogs with generated defaults. get_id_from_blogname() expects "/testpath1/" to be in the DB but the factory was creating "testpath1/".
comment:10
ryan
— 9 months ago
Still looking at the blog-lookup cache. In the unit tests sometimes the domain + path passed to get_blog_details() is "example.org" and sometimes "example.org/". I haven't yet looked at what mischief core does during blog creation.
comment:11
ryan
— 9 months ago
The domain and path used for the details blog-lookup key are consistent so far when testing blog create, delete, edit, and load. They're not slashed for the db AFAICT. I haven't tested through signup yet.
comment:12
ryan
— 9 months ago
The current_blog_* cache also appears consistent and not slashed for the DB when testing blog create, delete, edit, and load. This is while testing path based multisite. I haven't tested subdomain yet.
comment:13
ryan
— 9 months ago
In [21979]:
comment:14
ryan
— 9 months ago
comment:15
ryan
— 9 months ago
- Resolution set to fixed
- Status changed from assigned to closed
I feel dirty after debugging this. Here's the flow:
1) call wpmu_delete_blog()
2) It calls update_blog_status( $blog_id, 'deleted', 1 );
3) ...which calls refresh_blog_details($blog_id);
4) Which does:
5) ...but was missing:
One line patch.