mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@37324 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -258,6 +258,18 @@ class Tests_Query_Date extends WP_UnitTestCase {
|
||||
$this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 36718
|
||||
*/
|
||||
public function test_non_scalar_m_should_be_discarded() {
|
||||
$expected = $this->_get_query_result( );
|
||||
$posts = $this->_get_query_result( array(
|
||||
'm' => array( '1234' ), // ignored
|
||||
) );
|
||||
|
||||
$this->assertEquals( $expected, $posts );
|
||||
}
|
||||
|
||||
public function test_simple_monthnum_expecting_results() {
|
||||
$posts = $this->_get_query_result( array(
|
||||
'monthnum' => 5,
|
||||
|
||||
Reference in New Issue
Block a user