WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#31025 closed defect (bug) (fixed)

Searching by 0 (zero produces inconsistent results)

Reported by: jadpm Owned by: swissspidy
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch has-unit-tests good-first-bug commit
Focuses: administration Cc:

Description

Related to #11330

Searching by zero produces inconsistent results, both in the backend on edit.php pages and in frontend:

  • In the backend, the 0 is kept on the search input, no search term message is shown and no filtering is done.
  • In the frontend, the search results page is loaded, the search term is displayed if your theme provides it and again no filtering is done.

I have no patch ATM, this is a query issue and I am a newbie here, so any help is welcome.

Attachments (3)

31025.diff (8.3 KB) - added by swissspidy 4 years ago.
31025.2.diff (8.8 KB) - added by swissspidy 4 years ago.
31025.3.diff (8.8 KB) - added by swissspidy 4 years ago.

Download all attachments as: .zip

Change History (12)

#1 @DrewAPicture
4 years ago

  • Version trunk deleted

@swissspidy
4 years ago

#2 @swissspidy
4 years ago

  • Keywords has-patch has-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

The Search results for “%s” message never appears on any admin screen when searching for "0".

The attached patch changes this, as well as adds the ability to search for "0" to WP_Query.

#3 @swissspidy
4 years ago

  • Focuses administration added
  • Keywords needs-refresh good-first-bug added

Patch needs a slight refresh as I think this is still of value.

#4 @boonebgorges
4 years ago

  • Milestone changed from Future Release to 4.5

Thanks, @swissspidy.

The WP_Query test passes even without the patch :) We've got to throw a non-matching post in there to show that s=0 doesn't return it.

Also, isset( $q['s'] ) will always be true, because of fill_query_vars(). This will cause LIKE clauses to be added to every WP_Query request. Let's use strlen() instead.

#5 @boonebgorges
4 years ago

In 36278:

Support searching for '0' in WP_Query.

Props swissspidy.
See #31025.

#6 @boonebgorges
4 years ago

  • Owner set to swissspidy
  • Status changed from new to assigned

wp-admin changes look good to me, though I think we need a refresh on at least one of the files. I'll give you the honors.

@swissspidy
4 years ago

#7 @swissspidy
4 years ago

  • Keywords commit added; needs-refresh removed

31025.2.diff applies cleanly against trunk again. It enables searching for "0" throughout the admin (post types, users, comments, plugins).

Besides that I also added /* translators: %s: search keywords */ comments where missing.

Also, I found a bug in WP_Plugins_List_Table::_search_callback where it tries to search in array values instead of strings, throwing some warnings. I think that has to do with the recent addition of update information from the API to the plugin data (see #35301).

@swissspidy
4 years ago

#8 @swissspidy
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 36302:

Allow searching for 0 throughout the admin.

Fixes #31025.

#9 @boonebgorges
4 years ago

In 36520:

Make sure fixtures have empty post_content in search test.

The generator sequence was causing false positives when the search terms
('1' and '0') happened to match the current sequence number (eg,
'Post content 190').

Introduced in [36278].

See #31025.

Note: See TracTickets for help on using tickets.