Skip to content

Commit

Permalink
Don't split the main query if there is no limit. This helps avoid ext…
Browse files Browse the repository at this point in the history
…remely long query strings that could cause segfaults. Allow plugins to control splitting via split_the_query filter. see #20628

git-svn-id: http://core.svn.wordpress.org/trunk@20740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ryan committed May 8, 2012
1 parent f5366a2 commit bfe8265
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wp-includes/query.php
Expand Up @@ -2626,7 +2626,9 @@ function &get_posts() {
return $r;
}

if ( $old_request == $this->request && "$wpdb->posts.*" == $fields ) {
$split_the_query = apply_filters( 'split_the_query', ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits) ), $this );

if ( $split_the_query ) {
// First get the IDs and then fill in the objects

$this->request = "SELECT $found_rows $distinct $wpdb->posts.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
Expand Down

0 comments on commit bfe8265

Please sign in to comment.