Make WordPress Core

Changeset 41663


Ignore:
Timestamp:
10/02/2017 02:44:48 AM (7 years ago)
Author:
pento
Message:

Database: Fix some PHP errors introduced in [41662].

PHP < 5.4 requires a $matches parameter to be passed to preg_match_all()

wpdb::prepare() can be called before translations are loaded, so needs appropriate wp_load_translations_early() calls.

See #42040.

File:
1 edited

Legend:

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

    r41662 r41663  
    12311231        // This is not meant to be foolproof -- but it will catch obviously incorrect usage.
    12321232        if ( strpos( $query, '%' ) === false ) {
     1233            wp_load_translations_early();
    12331234            _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query argument of %s must have a placeholder.' ), 'wpdb::prepare()' ), '3.9.0' );
    12341235        }
     
    12441245        foreach ( $args as $arg ) {
    12451246            if ( ! is_scalar( $arg ) && ! is_null( $arg ) ) {
     1247                wp_load_translations_early();
    12461248                _doing_it_wrong( 'wpdb::prepare', sprintf( __( 'Unsupported value type (%s).' ), gettype( $arg ) ), '4.8.2' );
    12471249            }
     
    12551257
    12561258        // Count the number of valid placeholders in the query
    1257         $placeholders = preg_match_all( '/(^|[^%]|(%%)+)%[sdF]/', $query );
     1259        $placeholders = preg_match_all( '/(^|[^%]|(%%)+)%[sdF]/', $query, $matches );
    12581260
    12591261        if ( count ( $args ) !== $placeholders ) {
     1262            wp_load_translations_early();
    12601263            _doing_it_wrong( 'wpdb::prepare',
    12611264                sprintf( __( 'The query does not contain the correct number of placeholders (%d) for the number of arguments passed (%d).' ),
Note: See TracChangeset for help on using the changeset viewer.