Make WordPress Core

Changeset 36278


Ignore:
Timestamp:
01/13/2016 04:36:54 AM (9 years ago)
Author:
boonebgorges
Message:

Support searching for '0' in WP_Query.

Props swissspidy.
See #31025.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r36251 r36278  
    27762776
    27772777        // If a search pattern is specified, load the posts that match.
    2778         if ( ! empty( $q['s'] ) ) {
     2778        if ( strlen( $q['s'] ) ) {
    27792779            $search = $this->parse_search( $q );
    27802780        }
  • trunk/tests/phpunit/tests/query/search.php

    r36251 r36278  
    138138        $this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
    139139    }
     140
     141    /**
     142     * @ticket 31025
     143     */
     144    public function test_s_zero() {
     145        $p1 = $this->factory->post->create( array(
     146            'post_status' => 'publish',
     147            'post_title' => '1',
     148        ) );
     149
     150        $p2 = $this->factory->post->create( array(
     151            'post_status' => 'publish',
     152            'post_title' => '0',
     153        ) );
     154
     155        $q = new WP_Query( array(
     156            's' => '0',
     157            'fields' => 'ids',
     158        ) );
     159
     160        $this->assertEqualSets( array( $p2 ), $q->posts );
     161    }
    140162}
Note: See TracChangeset for help on using the changeset viewer.