Date/Time: In WP_Date_Query::__construct(), return early if $date_query is empty or not an array.

Props vishalkakadiya.
Fixes #47392.
Built from https://develop.svn.wordpress.org/trunk@45850


git-svn-id: http://core.svn.wordpress.org/trunk@45661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-08-19 15:17:56 +00:00
parent 7a92316fd8
commit 3541c5d74c
2 changed files with 6 additions and 10 deletions

View File

@ -145,25 +145,21 @@ class WP_Date_Query {
* 'comment_date', 'comment_date_gmt'. * 'comment_date', 'comment_date_gmt'.
*/ */
public function __construct( $date_query, $default_column = 'post_date' ) { public function __construct( $date_query, $default_column = 'post_date' ) {
if ( empty( $date_query ) || ! is_array( $date_query ) ) {
return;
}
if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) { if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
$this->relation = 'OR'; $this->relation = 'OR';
} else { } else {
$this->relation = 'AND'; $this->relation = 'AND';
} }
if ( ! is_array( $date_query ) ) {
return;
}
// Support for passing time-based keys in the top level of the $date_query array. // Support for passing time-based keys in the top level of the $date_query array.
if ( ! isset( $date_query[0] ) && ! empty( $date_query ) ) { if ( ! isset( $date_query[0] ) ) {
$date_query = array( $date_query ); $date_query = array( $date_query );
} }
if ( empty( $date_query ) ) {
return;
}
if ( ! empty( $date_query['column'] ) ) { if ( ! empty( $date_query['column'] ) ) {
$date_query['column'] = esc_sql( $date_query['column'] ); $date_query['column'] = esc_sql( $date_query['column'] );
} else { } else {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3-alpha-45827'; $wp_version = '5.3-alpha-45850';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.