Skip to content
Permalink
Browse files

Date/Time: In `WP_Date_Query::__construct()`, return early if `$date_…

…query` is empty or not an array.

Props vishalkakadiya.
Fixes #47392.

git-svn-id: https://develop.svn.wordpress.org/trunk@45850 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Aug 19, 2019
1 parent 4e0499e commit 0f8ba2cf2a004217a379e3dfea942a0ffe89688e
Showing with 5 additions and 9 deletions.
  1. +5 −9 src/wp-includes/class-wp-date-query.php
@@ -145,25 +145,21 @@ class WP_Date_Query {
* 'comment_date', 'comment_date_gmt'.
*/
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'] ) ) {
$this->relation = 'OR';
} else {
$this->relation = 'AND';
}
if ( ! is_array( $date_query ) ) {
return;
}
// 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 );
}
if ( empty( $date_query ) ) {
return;
}
if ( ! empty( $date_query['column'] ) ) {
$date_query['column'] = esc_sql( $date_query['column'] );
} else {

0 comments on commit 0f8ba2c

Please sign in to comment.
You can’t perform that action at this time.