WordPress.org

Make WordPress Core

Changeset 38507


Ignore:
Timestamp:
09/02/2016 12:18:49 AM (3 years ago)
Author:
pento
Message:

Database: Find the correct table names in DELETE queries with table aliases

Previously, wpdb::get_table_from_query() would not find the correct table name in the query DELETE a FROM table a, due to not recognising the table alias immediately after the DELETE as correct syntax.

Fixes #37660.

Location:
trunk
Files:
2 edited

Legend:

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

    r38441 r38507  
    30303030                . '|REPLACE(?:\s+LOW_PRIORITY|\s+DELAYED)?(?:\s+INTO)?'
    30313031                . '|UPDATE(?:\s+LOW_PRIORITY)?(?:\s+IGNORE)?'
    3032                 . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:\s+FROM)?'
     3032                . '|DELETE(?:\s+LOW_PRIORITY|\s+QUICK|\s+IGNORE)*(?:.+?FROM)?'
    30333033                . ')\s+((?:[0-9a-zA-Z$_.`-]|[\xC2-\xDF][\x80-\xBF])+)/is', $query, $maybe ) ) {
    30343034            return str_replace( '`', '', $maybe[1] );
  • trunk/tests/phpunit/tests/db.php

    r37602 r38507  
    563563            "DELETE IGNORE $table",
    564564            "DELETE LOW_PRIORITY FROM $table",
     565            "DELETE a FROM $table a",
     566            "DELETE `a` FROM $table a",
    565567
    566568            // STATUS
Note: See TracChangeset for help on using the changeset viewer.