Make WordPress Core

Changeset 45850


Ignore:
Timestamp:
08/19/2019 03:16:18 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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

Props vishalkakadiya.
Fixes #47392.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-date-query.php

    r45678 r45850  
    146146     */
    147147    public function __construct( $date_query, $default_column = 'post_date' ) {
     148        if ( empty( $date_query ) || ! is_array( $date_query ) ) {
     149            return;
     150        }
     151
    148152        if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) {
    149153            $this->relation = 'OR';
     
    152156        }
    153157
    154         if ( ! is_array( $date_query ) ) {
    155             return;
    156         }
    157 
    158158        // Support for passing time-based keys in the top level of the $date_query array.
    159         if ( ! isset( $date_query[0] ) && ! empty( $date_query ) ) {
     159        if ( ! isset( $date_query[0] ) ) {
    160160            $date_query = array( $date_query );
    161         }
    162 
    163         if ( empty( $date_query ) ) {
    164             return;
    165161        }
    166162
Note: See TracChangeset for help on using the changeset viewer.