Make WordPress Core


Ignore:
Timestamp:
10/31/2017 12:48:20 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.3 branch.
See #41925.

Location:
branches/4.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3

  • branches/4.3/tests/phpunit/tests/date/query.php

    r31251 r42062  
    602602
    603603    public function test_build_time_query_hour_minute() {
     604        global $wpdb;
    604605        $q = new WP_Date_Query( array() );
    605606
     
    608609        // $compare value is floating point - use regex to account for
    609610        // varying precision on different PHP installations
    610         $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $found );
     611        $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) );
    611612    }
    612613
    613614    public function test_build_time_query_hour_minute_second() {
     615        global $wpdb;
    614616        $q = new WP_Date_Query( array() );
    615617
     
    618620        // $compare value is floating point - use regex to account for
    619621        // varying precision on different PHP installations
    620         $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $found );
     622        $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) );
    621623    }
    622624
    623625    public function test_build_time_query_minute_second() {
     626        global $wpdb;
    624627        $q = new WP_Date_Query( array() );
    625628
     
    628631        // $compare value is floating point - use regex to account for
    629632        // varying precision on different PHP installations
    630         $this->assertRegExp( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $found );
     633        $this->assertRegExp( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) );
    631634    }
    632635
Note: See TracChangeset for help on using the changeset viewer.