[wp-trac] [WordPress Trac] #25316: Inconsistent behavior in wpmu_current_site() that impacts external object caches
WordPress Trac
noreply at wordpress.org
Fri Sep 13 17:51:08 UTC 2013
#25316: Inconsistent behavior in wpmu_current_site() that impacts external object
caches
--------------------------+-----------------------------
Reporter: gradyetc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0
Severity: minor | Keywords:
--------------------------+-----------------------------
We're running a multisite sub-directory install, using the Networks for
WordPress to serve multiple domains from one install. We're also using
memcached as a persistent object cache.
Since we need to support multiple networks we do not set the
DOMAIN_CURRENT_SITE or PATH_CURRENT_SITE constants as instructed by the
[http://codex.wordpress.org/Create_A_Network network install
instructions].
We've noticed some odd behavior after a fresh install, before we add
additional networks due to logic in wpmu_current_site().
Excerpting the relevant code from ms-load.php:
{{{
$current_site = wp_cache_get( 'current_site', 'site-options' );
if ( $current_site )
return $current_site;
$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually
only one site
if ( 1 == count( $sites ) ) {
$current_site = $sites[0];
wp_load_core_site_options( $current_site->id );
$path = $current_site->path;
$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT
blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s",
$current_site->domain, $current_site->path ) );
$current_site = get_current_site_name( $current_site );
if ( substr( $current_site->domain, 0, 4 ) == 'www.' )
$current_site->cookie_domain = substr(
$current_site->domain, 4 );
wp_cache_set( 'current_site', $current_site, 'site-options' );
return $current_site;
}
}}}
When the 'current_site' cache item exists, the $domain and $path globals
are not updated to reflect the cached values before returning. This is
inconsistent with behavior exhibited when cached values do not exist. The
end result is that trying to access pages on non-root sites (blogs)
results in a 404 since the current site (blog) is not set correctly.
We get around this by installing another network and flushing the cache
(after which the 'current_site' cache item is never set).
It's a minor issue, but I would think the $path and $domain variables
should be set consistently.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25316>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list