#25835 closed defect (bug) (fixed)
WP_Date_Query duplicated Parameters
Reported by: | ChriCo | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.0 | Priority: | low |
Severity: | normal | Version: | 3.7 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
In WP_Date_Query-Class there a 2 duplicated Parameters:
- month <-> monthnum
- week <-> w
When creating an Query, we can set both of them:
$date_query = new WP_Date_Query( array( 'w' => 12, 'week' => 11 )); echo $date_query->get_sql(); /* AND ( ( WEEK( post_date, 1 ) = 11 AND WEEK( post_date, 1 ) = 12 ) ) */
and:
$date_query = new WP_Date_Query( array( 'month' => 12, 'monthnum' => 11 )); echo $date_query->get_sql(); /* AND ( ( MONTH( post_date ) = 12 AND MONTH( post_date ) = 11 ) ) */
In date.php should be an else if to avoid the duplicated AND-Search with no result at all:
if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; else if ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) $where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
and..
if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) $where_parts[] = "MONTH( $column ) $compare $value"; else if ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) $where_parts[] = "MONTH( $column ) $compare $value";
Attachments (4)
Change History (16)
#4
@
11 years ago
that .rej
is not what we need:
http://make.wordpress.org/core/handbook/working-with-trac/submitting-a-patch/
#6
@
11 years ago
- Keywords has-patch needs-unit-tests added
- Milestone changed from Awaiting Review to 3.9
#7
@
11 years ago
Hope the unit test works. Also uploaded the diff with the whole change since the path to the file has changed.
#8
@
11 years ago
- Keywords needs-unit-tests removed
Wasn't happy with the tests uploaded before so I added one more assert to each test to check for returned posts.
#10
@
11 years ago
- Milestone changed from 3.9 to Future Release
- Priority changed from normal to low
This isn't a huge deal, moving to Future, we can pick it up in 4.0.
Note: See
TracTickets for help on using
tickets.
Related: #25834