[wp-trac] [WordPress Trac] #25316: Inconsistent behavior in wpmu_current_site() when using persistent object cache
WordPress Trac
noreply at wordpress.org
Fri Sep 13 18:27:42 UTC 2013
#25316: Inconsistent behavior in wpmu_current_site() when using persistent object
cache
--------------------------+------------------------------
Reporter: gradyetc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Multisite | Version: 3.0
Severity: minor | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by gradyetc):
>>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.
>Could you explain this? I only see $domain and $path used in two places:
ms_not_installed(), and during signups.
Lines 66 through 80 in wp-includes/ms-settings.php.
{{{
$blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen(
$path ) ) );
if ( false !== strpos( $blogname, '/' ) )
$blogname = substr( $blogname, 0, strpos( $blogname, '/' ) );
if ( false !== strpos( $blogname, '?' ) )
$blogname = substr( $blogname, 0, strpos( $blogname, '?' ) );
$reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-
includes', 'wp-content', 'files', 'feed' );
if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && !
is_file( $blogname ) )
$path .= $blogname . '/';
$current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-
options' );
if ( ! $current_blog ) {
$current_blog = get_blog_details( array( 'domain' => $domain,
'path' => $path ), false );
if ( $current_blog )
wp_cache_set( 'current_blog_' . $domain . $path,
$current_blog, 'site-options' );
}
unset($reserved_blognames);
}}}
It derives $blogname from $path. If it isn't set appropriately by
wpmu_current_site when called on line 48, it messes up everything that
tries to populate $current_blog after it.
Took me a while to trace this ... globals are fun if you like surprises.
:)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25316#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list