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.

Merges [33259] to the 4.2 branch.

Fixes #32763


Built from https://develop.svn.wordpress.org/branches/4.2@33260


git-svn-id: http://core.svn.wordpress.org/branches/4.2@33232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2015-07-14 10:21:26 +00:00
parent 7090cf8980
commit c43baf9ef4

View File

@ -2833,11 +2833,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*(?:'