diff --git src/wp-includes/date.php src/wp-includes/date.php
index 0c42766..ed8fff7 100644
|
|
|
class WP_Date_Query {
|
| 256 | 256 | |
| 257 | 257 | if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) |
| 258 | 258 | $where_parts[] = "MONTH( $column ) $compare $value"; |
| 259 | | |
| 260 | | // Legacy |
| 261 | | if ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) |
| | 259 | else if ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) |
| 262 | 260 | $where_parts[] = "MONTH( $column ) $compare $value"; |
| 263 | 261 | |
| 264 | 262 | if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) |
| 265 | 263 | $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
| 266 | | |
| 267 | | // Legacy |
| 268 | | if ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) |
| | 264 | else if ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) |
| 269 | 265 | $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
| 270 | 266 | |
| 271 | 267 | if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) |
diff --git tests/phpunit/tests/query/dateQuery.php tests/phpunit/tests/query/dateQuery.php
index 47cc71d..17fe779 100644
|
|
|
class Tests_Query_DateQuery extends WP_UnitTestCase {
|
| 555 | 555 | |
| 556 | 556 | $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); |
| 557 | 557 | } |
| | 558 | |
| | 559 | public function test_date_params_monthnum_m_duplicate() { |
| | 560 | $this->q->query( array( |
| | 561 | 'date_query' => array( |
| | 562 | 'month' => 10, |
| | 563 | 'monthnum' => 11 |
| | 564 | ), |
| | 565 | ) ); |
| | 566 | |
| | 567 | $this->assertContains( "AND ( ( MONTH( post_date ) = 10 ) ) AND", $this->q->request ); |
| | 568 | |
| | 569 | $this->assertNotContains( "AND ( ( MONTH( post_date ) = 10 AND MONTH( post_date ) = 11 ) ) AND", $this->q->request ); |
| | 570 | } |
| | 571 | |
| | 572 | public function test_date_params_week_w_duplicate() { |
| | 573 | $this->q->query( array( |
| | 574 | 'date_query' => array( |
| | 575 | 'week' => 10, |
| | 576 | 'w' => 11 |
| | 577 | ), |
| | 578 | ) ); |
| | 579 | |
| | 580 | $this->assertContains( "AND ( ( WEEK( post_date, 1 ) = 10 ) ) AND", $this->q->request ); |
| | 581 | |
| | 582 | $this->assertNotContains( "AND ( ( WEEK( post_date, 1 ) = 10 AND WEEK( post_date, 1 ) = 11 ) ) AND", $this->q->request ); |
| | 583 | } |
| 558 | 584 | } |
| | 585 | No newline at end of file |