Make WordPress Core


Ignore:
Timestamp:
10/31/2017 12:33:25 PM (8 years ago)
Author:
pento
Message:

Database: Restore numbered placeholders in wpdb::prepare().

[41496] removed support for numbered placeholders in queries send through wpdb::prepare(), which, despite being undocumented, were quite commonly used.

This change restores support for numbered placeholders (as well as a subset of placeholder formatting), while also adding extra checks to ensure the correct number of arguments are being passed to wpdb::prepare(), given the number of placeholders.

Merges [41662], [42056] to the 4.7 branch.
See #41925.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/tests/phpunit/tests/comment/query.php

    r39274 r42058  
    12191219     */
    12201220    public function test_search_int_0_should_not_be_ignored() {
     1221        global $wpdb;
    12211222        $q = new WP_Comment_Query();
    12221223        $q->query( array(
    12231224            'search' => 0,
    12241225        ) );
    1225         $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1226        $this->assertContains( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) );
    12261227    }
    12271228
     
    12301231     */
    12311232    public function test_search_string_0_should_not_be_ignored() {
     1233        global $wpdb;
    12321234        $q = new WP_Comment_Query();
    12331235        $q->query( array(
    12341236            'search' => '0',
    12351237        ) );
    1236         $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1238        $this->assertContains( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) );
    12371239    }
    12381240
Note: See TracChangeset for help on using the changeset viewer.