WordPress.org

Make WordPress Core

Changeset 31251


Ignore:
Timestamp:
01/20/2015 07:12:48 PM (6 years ago)
Author:
boonebgorges
Message:

WP_Date_Query date validation should not fail for hour = 0.

Props ChriCo, tyxla.
Fixes #31067 for trunk.

Location:
trunk
Files:
2 edited

Legend:

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

    r31217 r31251  
    369369        // Hours per day.
    370370        $min_max_checks['hour'] = array(
    371             'min' => 1,
     371            'min' => 0,
    372372            'max' => 23
    373373        );
     
    395395                $is_between = $_value >= $check['min'] && $_value <= $check['max'];
    396396
    397                 if ( ! $is_between ) {
     397                if ( ! is_numeric( $_value ) || ! $is_between ) {
    398398                    $error = sprintf(
    399399                        /* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */
  • trunk/tests/phpunit/tests/date/query.php

    r31179 r31251  
    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.