Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#31025 closed defect (bug) (fixed)

Searching by 0 (zero produces inconsistent results)

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


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 9 years ago.
31025.2.diff (8.8 KB) - added by swissspidy 9 years ago.
31025.3.diff (8.8 KB) - added by swissspidy 9 years ago.

Download all attachments as: .zip

Change History (12)

#1 @DrewAPicture
9 years ago

  • Version trunk deleted

9 years ago

#2 @swissspidy
9 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
9 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
9 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
9 years ago

In 36278:

Support searching for '0' in WP_Query.

Props swissspidy.
See #31025.

#6 @boonebgorges
9 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.

9 years ago

#7 @swissspidy
9 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).

9 years ago

#8 @swissspidy
9 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
8 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.