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. Built from https://develop.svn.wordpress.org/trunk@41663 git-svn-id: http://core.svn.wordpress.org/trunk@41497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1603a9e067
commit
f0492c5da8
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41662';
|
||||
$wp_version = '4.9-alpha-41663';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -1230,6 +1230,7 @@ class wpdb {
|
|||
|
||||
// This is not meant to be foolproof -- but it will catch obviously incorrect usage.
|
||||
if ( strpos( $query, '%' ) === false ) {
|
||||
wp_load_translations_early();
|
||||
_doing_it_wrong( 'wpdb::prepare', sprintf( __( 'The query argument of %s must have a placeholder.' ), 'wpdb::prepare()' ), '3.9.0' );
|
||||
}
|
||||
|
||||
|
@ -1243,6 +1244,7 @@ class wpdb {
|
|||
|
||||
foreach ( $args as $arg ) {
|
||||
if ( ! is_scalar( $arg ) && ! is_null( $arg ) ) {
|
||||
wp_load_translations_early();
|
||||
_doing_it_wrong( 'wpdb::prepare', sprintf( __( 'Unsupported value type (%s).' ), gettype( $arg ) ), '4.8.2' );
|
||||
}
|
||||
}
|
||||
|
@ -1254,9 +1256,10 @@ class wpdb {
|
|||
$query = preg_replace( '/%(?:%|$|([^dsF]))/', '%%\\1', $query ); // escape any unescaped percents
|
||||
|
||||
// Count the number of valid placeholders in the query
|
||||
$placeholders = preg_match_all( '/(^|[^%]|(%%)+)%[sdF]/', $query );
|
||||
$placeholders = preg_match_all( '/(^|[^%]|(%%)+)%[sdF]/', $query, $matches );
|
||||
|
||||
if ( count ( $args ) !== $placeholders ) {
|
||||
wp_load_translations_early();
|
||||
_doing_it_wrong( 'wpdb::prepare',
|
||||
sprintf( __( 'The query does not contain the correct number of placeholders (%d) for the number of arguments passed (%d).' ),
|
||||
$placeholders,
|
||||
|
|
Loading…
Reference in New Issue