WPDB: When extracting the table name from a query, we had a 1000 character limit on the SQL string that would be searched. This was a hangover from when the code was imported from HyperDB, and isn't appropriate for Core, where a wider range of queries are likely to be run.

Fixes #32763



git-svn-id: https://develop.svn.wordpress.org/trunk@33259 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2015-07-14 10:18:57 +00:00
parent 56c51da216
commit 7711b72639
2 changed files with 7 additions and 5 deletions

View File

@ -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*(?:'

View File

@ -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 );