From bfe82654d64d81925f31032b7f109b27c8837210 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 8 May 2012 20:01:47 +0000 Subject: [PATCH] Don't split the main query if there is no limit. This helps avoid extremely 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 --- wp-includes/query.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 11849503c..3cb2384a8 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2626,7 +2626,9 @@ class WP_Query { 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";