WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/26/2016 03:11:12 AM (5 years ago)
Author:
boonebgorges
Message:

Query: Respect 'suppress_filters' when filtering search-related SQL.

Props 5um17.
Fixes #35594.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/search.php

    r36278 r36404  
    160160        $this->assertEqualSets( array( $p2 ), $q->posts );
    161161    }
     162
     163    /**
     164     * @ticket 35594
     165     */
     166    public function test_search_should_respect_suppress_filters() {
     167        add_filter( 'posts_search', array( $this, 'filter_posts_search' ) );
     168        add_filter( 'posts_search_orderby', array( $this, 'filter_posts_search' ) );
     169        $q = new WP_Query( array(
     170            's' => 'foo',
     171            'suppress_filters' => true,
     172        ) );
     173        remove_filter( 'posts_search', array( $this, 'filter_posts_search' ) );
     174        remove_filter( 'posts_search_orderby', array( $this, 'filter_posts_search' ) );
     175
     176        $this->assertNotContains( 'posts_search', $q->request );
     177    }
     178
     179    public function filter_posts_search( $sql ) {
     180        return $sql . ' /* posts_search */';
     181    }
    162182}
Note: See TracChangeset for help on using the changeset viewer.