[wp-trac] [WordPress Trac] #23405: blog-details cache can get stuck with bad value
WordPress Trac
noreply at wordpress.org
Wed Feb 6 11:13:09 UTC 2013
#23405: blog-details cache can get stuck with bad value
--------------------------+------------------------------
Reporter: westi | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Multisite | Version: 3.5.1
Severity: normal | Resolution:
Keywords: needs-patch |
--------------------------+------------------------------
Description changed by westi:
Old description:
> 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 :(
New description:
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 :(
--
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23405#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list