Make WordPress Core

Changeset 33260


Ignore:
Timestamp:
07/14/2015 10:20:55 AM (11 years ago)
Author:
pento
Message:

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

Location:
branches/4.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/src/wp-includes/wp-db.php

    r33063 r33260  
    28342834                $query = ltrim( $query, "\r\n\t (" );
    28352835
    2836                 /*
    2837                  * Strip everything between parentheses except nested selects and use only 1,000
    2838                  * chars of the query.
    2839                  */
    2840                 $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', substr( $query, 0, 1000 ) );
     2836                // Strip everything between parentheses except nested selects.
     2837                $query = preg_replace( '/\((?!\s*select)[^(]*?\)/is', '()', $query );
    28412838
    28422839                // Quickly match most common queries.
  • branches/4.2/tests/phpunit/tests/db.php

    r32370 r33260  
    534534                        "SELECT * FROM `$table`",
    535535
     536                        "SELECT * FROM (SELECT * FROM $table) as subquery",
     537
    536538                        "INSERT $table",
    537539                        "INSERT IGNORE $table",
    … …  
    628630                        "SHOW CREATE TABLE $table",
    629631                        "SHOW INDEX FROM $table",
     632
     633                        // @ticket 32763
     634                        "SELECT " . str_repeat( 'a', 10000 ) . " FROM (SELECT * FROM $table) as subquery",
    630635                );
    631636
Note: See TracChangeset for help on using the changeset viewer.