diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 2f6d4f484c..cbf2abf77f 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -2868,11 +2868,8 @@ class wpdb { // Allow (select...) union [...] style queries. Use the first query's table name. $query = ltrim( $query, "\r\n\t (" ); - /* - * Strip everything between parentheses except nested selects and use only 1,000 - * chars of the query. - */ - $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', substr( $query, 0, 1000 ) ); + // Strip everything between parentheses except nested selects. + $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', $query ); // Quickly match most common queries. if ( preg_match( '/^\s*(?:' diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index a8524aa2cb..9a6be9f30b 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -533,6 +533,8 @@ class Tests_DB extends WP_UnitTestCase { "SELECT * FROM $table", "SELECT * FROM `$table`", + "SELECT * FROM (SELECT * FROM $table) as subquery", + "INSERT $table", "INSERT IGNORE $table", "INSERT IGNORE INTO $table", @@ -627,6 +629,9 @@ class Tests_DB extends WP_UnitTestCase { "SHOW FULL COLUMNS FROM $table", "SHOW CREATE TABLE $table", "SHOW INDEX FROM $table", + + // @ticket 32763 + "SELECT " . str_repeat( 'a', 10000 ) . " FROM (SELECT * FROM $table) as subquery", ); $querycount = count( $queries );