#23405 closed defect (bug) (fixed)
blog-details cache can get stuck with bad value
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 3.6 | Priority: | normal |
| Severity: | normal | Version: | 3.5.1 |
| Component: | Multisite | Keywords: | has-patch |
| Focuses: | Cc: |
Description (last modified by )
If you call get_blog_details for a blog which doesn't exist yet in wp_blogs then we cache a negative lookup result as -1:
https://core.trac.wordpress.org/browser/trunk/wp-includes/ms-blogs.php?rev=23389#L217
if ( empty($details) ) {
$details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id ) );
if ( ! $details ) {
// Set the full cache.
wp_cache_set( $blog_id, -1, 'blog-details' );
return false;
}
}
When you then later call refresh_blog_details to clear up the cache for the blog_id the cached -1 is passed to clean_blog_cache which then tries to get a blog_id from the object that was returned and doesn't get the right one and the cached are not deleted.
This means that the blog ends up broken :(
Attachments (3)
Change History (10)
#3
@
13 years ago
- Keywords has-patch added; needs-patch removed
The above patch seems to do the job, the test below confirms:
<?php
require_once('./wp-load.php');
global $wpdb;
$next_id = $wpdb->get_var(
"SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".DB_NAME."' "
." AND TABLE_NAME = '{$wpdb->blogs}'"
);
echo '<pre>';
echo "Next blog id to be added $next_id \n\n";
echo "get_blog_details(1): \n\n";
echo var_export(get_blog_details(1))."\n\n";
echo "get_blog_details($next_id): \n";
echo var_export(get_blog_details($next_id))."\n\n";
$new_blog = wpmu_create_blog(get_bloginfo('domain'), 'secondblog', 'Second Blog',
1);
echo "added blog $new_blog and refresh_blog_details($new_blog) \n\n";
refresh_blog_details($new_blog);
echo "get_blog_details($next_id) \n\n";
echo var_export(get_blog_details($next_id))."\n\n";
echo "cleaning up \n\n";
wpmu_delete_blog($new_blog, true);
echo '</pre>';
#4
@
13 years ago
- Cc hirozed added
The above patch (the .2 version) checks for the result of -1 from $details and passes null for domain and path, which should satisfy clean_blog_cache.
Note: See
TracTickets for help on using
tickets.
Force clearing 'blog-details' cache in refresh_blog_details if no details returned from first call to get_blog_details