Make WordPress Core


Ignore:
Timestamp:
10/31/2017 12:40:24 PM (6 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.6 branch.
See #41925.

Location:
branches/4.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

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

    r38537 r42059  
    12231223     */
    12241224    public function test_search_int_0_should_not_be_ignored() {
     1225        global $wpdb;
    12251226        $q = new WP_Comment_Query();
    12261227        $q->query( array(
    12271228            'search' => 0,
    12281229        ) );
    1229         $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1230        $this->assertContains( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) );
    12301231    }
    12311232
     
    12341235     */
    12351236    public function test_search_string_0_should_not_be_ignored() {
     1237        global $wpdb;
    12361238        $q = new WP_Comment_Query();
    12371239        $q->query( array(
    12381240            'search' => '0',
    12391241        ) );
    1240         $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1242        $this->assertContains( "comment_author LIKE '%0%'", $wpdb->remove_placeholder_escape( $q->request ) );
    12411243    }
    12421244
Note: See TracChangeset for help on using the changeset viewer.