WP_Date_Query: The inclusive logic should include all times within the date range.

props mboynes, oso96_2000, DrewAPicture.
fixes #26653.
Built from https://develop.svn.wordpress.org/trunk@28935


git-svn-id: http://core.svn.wordpress.org/trunk@28733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-07-01 01:18:15 +00:00
parent 7a47b7585d
commit 7e226aaa70
2 changed files with 11 additions and 4 deletions

View File

@ -48,6 +48,9 @@ class WP_Date_Query {
/**
* Constructor.
*
* @since 3.7.0
* @since 4.0.0 The $inclusive logic was updated to include all times within the date range.
*
* @param array $date_query {
* One or more associative arrays of date query parameters.
*
@ -235,19 +238,23 @@ class WP_Date_Query {
$compare = $this->get_compare( $query );
$inclusive = ! empty( $query['inclusive'] );
// Assign greater- and less-than values.
$lt = '<';
$gt = '>';
if ( ! empty( $query['inclusive'] ) ) {
if ( $inclusive ) {
$lt .= '=';
$gt .= '=';
}
// Range queries
if ( ! empty( $query['after'] ) )
$where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], true ) );
$where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );
if ( ! empty( $query['before'] ) )
$where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], false ) );
$where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );
// Specific value queries

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.0-alpha-20140630';
$wp_version = '4.0-alpha-20140701';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.