[wpmu-trac] [WordPress MU Trac] #904: WPMU performs a blog-specific
query without switching to the blog, messing up HyperDB
WordPress MU Trac
wpmu-trac at lists.automattic.com
Tue Feb 17 23:03:42 GMT 2009
#904: WPMU performs a blog-specific query without switching to the blog, messing
up HyperDB
-------------------------+--------------------------------------------------
Reporter: markjaquith | Owner: donncha
Type: defect | Status: new
Priority: high | Milestone: 2.8
Component: General | Version: 2.7
Severity: major | Keywords:
-------------------------+--------------------------------------------------
When WPMU is installed with blogs in subdirectories, it needs to determine
whether a request for {{{site.com/something/}}} is for a blog called
"something" or for a page on site.com's main blog called "something."
It does this by querying the page slugs for site.com's main blog in
{{{is_blogname_page()}}}. It looks like this.
{{{
SELECT LOWER(post_name) FROM wp_1_posts WHERE post_type='page'
}}}
But at this point, {{{$wpdb->blogid}}} isn't set.
If you're using HyperDB, {{{$wpdb->prefix}}} won't be set because HyperDB
refuses to set {{{$wpdb->prefix}}} if {{{$wpdb->blogid}}} is empty. That
makes HyperDB's {{{get_ds_part_from_table()}}} method misbehave. It looks
at 'wp_1_posts' and does this:
{{{
preg_match('/^' . $this->prefix . '([a-z0-9]+)_([0-9a-f]{1,3})_/',
$table, $matches)
}}}
That MATCHES, because {{{$this->prefix}}} is blank. Then, HyperDB tries
to iterate through DB Servers with DataStore "wp" and partition "1" --
which aren't set.
One fix is for HyperDB to allow {{{->prefix}}} to be set to what is passed
to it, even if {{{->blogid}}} isn't set. But really, I think this is a
WPMU bug, because WPMU is making a blog-specific request without switching
to that blog.
--
Ticket URL: <http://trac.mu.wordpress.org/ticket/904>
WordPress MU Trac <http://mu.wordpress.org/>
WordPress Multiuser
More information about the wpmu-trac
mailing list