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. git-svn-id: https://develop.svn.wordpress.org/trunk@41663 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b4a6de9997
commit
d16b885730
@ -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
Block a user