In WP_Date_Query::get_sql_for_subquery(), don't parse duplicate parameters - only parse one of w and week or month and monthnum.

Adds unit tests.

Props oso96_2000, ChriCo.
Fixes #25835.


Built from https://develop.svn.wordpress.org/trunk@28252


git-svn-id: http://core.svn.wordpress.org/trunk@28080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-04 23:07:14 +00:00
parent a2067a7324
commit f90a558df4

View File

@ -256,16 +256,12 @@ class WP_Date_Query {
if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) )
$where_parts[] = "MONTH( $column ) $compare $value";
// Legacy
if ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) )
else if ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) )
$where_parts[] = "MONTH( $column ) $compare $value";
if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) )
$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
// Legacy
if ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) )
else if ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) )
$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) )