WordPress.org

Make WordPress Core

Ticket #26653: date.php.diff

File date.php.diff, 1022 bytes (added by mboynes, 8 years ago)

Resolves date query before/after logic when "inclusive" is set to true

  • wp-includes/date.php

     
    235235
    236236                $compare = $this->get_compare( $query );
    237237
     238                $inclusive = ! empty( $query['inclusive'] );
     239
    238240                $lt = '<';
    239241                $gt = '>';
    240                 if ( ! empty( $query['inclusive'] ) ) {
     242                if ( $inclusive ) {
    241243                        $lt .= '=';
    242244                        $gt .= '=';
    243245                }
    244246
    245247                // Range queries
    246248                if ( ! empty( $query['after'] ) )
    247                         $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], true ) );
     249                        $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) );
    248250
    249251                if ( ! empty( $query['before'] ) )
    250                         $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], false ) );
     252                        $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) );
    251253
    252254                // Specific value queries
    253255