WordPress.org

Make WordPress Core

#25587 closed defect (bug) (maybelater)

wp_search_stopwords filter shouldn't be cached

Reported by: alex-ye Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.7
Component: Query Keywords: has-patch
Focuses: Cc:

Description

Caching wp_search_stopwords hook, make it harder to remove the filter and add other filters after the function invoke.

Some reasons:

  • When we make a dynamic stopwords list depending on the 'Input language' or the WP query object.
  • I may add some stopwords using the ar.php file in wp-content/languages , becuase Arabic language has more than 1000 stopword. so I want to provide the ability to remove the filter easily!

Attachments (1)

25587.patch (1.2 KB) - added by alex-ye 22 months ago.

Download all attachments as: .zip

Change History (8)

@alex-ye22 months ago

comment:1 @alex-ye22 months ago

  • Keywords needs-testing added

comment:2 @SergeyBiryukov22 months ago

  • Version set to trunk

comment:3 follow-up: @azaozz22 months ago

Arabic language has more than 1000 stopword.

Keep in mind that WordPress should use the shortest list of stopwords possible. The default English stopwords are approximately what the search engines use, however there is a much longer list used in MySQL for full-text queries which is not suitable.

comment:4 in reply to: ↑ 3 @alex-ye22 months ago

Replying to azaozz:

Arabic language has more than 1000 stopword.

Keep in mind that WordPress should use the shortest list of stopwords possible. The default English stopwords are approximately what the search engines use, however there is a much longer list used in MySQL for full-text queries which is not suitable.

OK..

So is there any real reason about why wp_search_stopwords filter is cached?

comment:5 @SergeyBiryukov20 months ago

  • Version changed from trunk to 3.7

comment:6 @nacin19 months ago

  • Component changed from General to Query

comment:7 @wonderboymusic15 months ago

  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

You can filter every object instance of WP_Query differently:

function a_whatever() {
    remove_filter( 'wp_search_stopwords', __FUNCTION__ );

    // do whatever you want
}

function b_whatever() {
    remove_filter( 'wp_search_stopwords', __FUNCTION__ );

    // do whatever you want differently
}

add_filter( 'wp_search_stopwords', 'a_whatever' );

$q = new WP_Query( array( 's' => 'woo' ) );

add_filter( 'wp_search_stopwords', 'b_whatever' );

$q = new WP_Query( array( 's' => 'hoo' ) );

I don't see a great use case for filtering the same object multiple times. If there is one, please enlighten us and reopen.

Note: See TracTickets for help on using tickets.