WordPress.org

Make WordPress Core

Changeset 31377 for branches/4.1


Ignore:
Timestamp:
02/09/2015 02:32:31 AM (6 years ago)
Author:
dd32
Message:

WP_Date_Query date validation should not fail for hour = 0.

Props ChriCo, tyxla.
Merges [31251] to the 4.1 branch.
Fixes #31067.

Location:
branches/4.1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/src/wp-includes/date.php

    r30751 r31377  
    361361        // Hours per day.
    362362        $min_max_checks['hour'] = array(
    363             'min' => 1,
     363            'min' => 0,
    364364            'max' => 23
    365365        );
     
    385385            $is_between = $date_query[ $key ] >= $check['min'] && $date_query[ $key ] <= $check['max'];
    386386
    387             if ( ! $is_between ) {
     387            if ( ! is_numeric( $date_query[ $key ] ) || ! $is_between ) {
    388388
    389389                $error = sprintf(
  • branches/4.1/tests/phpunit/tests/date/query.php

    r30142 r31377  
    858858    public function test_validate_date_values_hour() {
    859859        // Valid values.
    860         $hours = range( 1, 23 );
     860        $hours = range( 0, 23 );
    861861        foreach ( $hours as $hour ) {
    862862            $this->assertTrue( $this->q->validate_date_values( array( 'hour' => $hour ) ) );
     
    864864
    865865        // Invalid values.
    866         $hours = array( -1, 24, 25, 'string who wants to be a int' );
     866        $hours = array( -1, 24, 25, 'string' );
    867867        foreach ( $hours as $hour ) {
    868868            $this->assertFalse( $this->q->validate_date_values( array( 'hour' => $hour ) ) );
Note: See TracChangeset for help on using the changeset viewer.