[wp-trac] [WordPress Trac] #10964: Improving query_posts performance
WordPress Trac
wp-trac at lists.automattic.com
Thu Feb 25 15:29:03 UTC 2010
#10964: Improving query_posts performance
-------------------------+--------------------------------------------------
Reporter: buch0090 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 3.0
Component: Performance | Version: 2.8.4
Severity: normal | Keywords: has-patch tested
-------------------------+--------------------------------------------------
Comment(by willmot):
Current patch has issues with taxonomy/term queries.
a query like
{{{
WP_Query( 'taxonomy=person&term=dave' );
}}}
Causes an SQL error [Unknown column 'p2.post_status' in 'where clause']
This is caused because on line 1940
{{{
$post_status_join = true;
}}}
Then lines 2119 - 2123
{{{
if ( $post_status_join ) {
$join .= " LEFT JOIN $wpdb->posts AS p2 ON
($wpdb->posts.post_parent = p2.ID) ";
foreach ( $statuswheres as $index => $statuswhere )
$statuswheres[$index] = "($statuswhere OR
($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts,
'p2', $statuswhere) . "))";
}
}}}
The $where is passed on to the quick request but the join is not and so we
end up trying to query a column from a table we haven't joined to.
I haven't patched as I am not totally sure why the taxonomy code block
sets $post_status_join = true;, my solution would be simply to remove line
1940
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10964#comment:25>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list