[wp-trac] [WordPress Trac] #25835: WP_Date_Query duplicated Parameters

WordPress Trac noreply at wordpress.org
Tue Nov 5 12:27:57 UTC 2013


#25835: WP_Date_Query duplicated Parameters
--------------------------+-----------------------------
 Reporter:  ChriCo        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Date/Time     |    Version:  3.7.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 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 [http://core.trac.wordpress.org/browser/branches/3.7/src/wp-
 includes/date.php 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";
 }}}

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25835>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list