Make WordPress Core


Ignore:
Timestamp:
04/29/2016 01:14:18 PM (8 years ago)
Author:
boonebgorges
Message:

Query: Discard non-scalar 'm' instead of attempting to sanitize.

WP_Query discards most non-array date values ('year', 'monthnum', etc) by
casting to integer. Since [25138], the 'm' parameter has been handled
as a string; see #24884. However, the string-handling introduced in [25138]
blindly attempted to handle arrays and other non-scalar types as strings,
resulting in PHP notices and invalid MySQL syntax.

Props vortfu.
Fixes #36718.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/date.php

    r35186 r37324  
    259259    }
    260260
     261    /**
     262     * @ticket 36718
     263     */
     264    public function test_non_scalar_m_should_be_discarded() {
     265        $expected = $this->_get_query_result( );
     266        $posts    = $this->_get_query_result( array(
     267            'm' => array( '1234' ), // ignored
     268        ) );
     269
     270        $this->assertEquals( $expected, $posts );
     271    }
     272
    261273    public function test_simple_monthnum_expecting_results() {
    262274        $posts = $this->_get_query_result( array(
Note: See TracChangeset for help on using the changeset viewer.