Search for 0 and get the accounts matching it - #717
Merged
Conversation
PHP reads the string "0" as empty, and three guards on the way from the search box to the query used empty() to mean "nothing was typed". So a search for 0 was dropped at the first of them, the request went out carrying no text filter at all, and the user got the whole unfiltered list back — not no matches, which would at least have looked like an answer. The tokenizer, the search service and the repository each compare against the empty string instead. 0 is a term like any other: a host ending in one, a version, a note that mentions it. Reachable from the search box and from the API's text parameter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
PHP reads the string
"0"as empty, and three guards between the search box and the query usedempty()to mean nothing was typed:AccountSearchTokenizer::tokenizeFrom()0AccountSearch::getByFilter()(service)AccountSearch::buildTextFilter()(repository)The first alone was enough: the request went out with no text filter at all, so a user searching for
0got the whole unfiltered list back — not "no matches", which would at least have looked like an answer.Reachable from the account search box and from the API's
textparameter.The fix
Each of the three compares against the empty string instead.
0is a search term like any other: a host ending in one, a version number, a note that mentions it.Testing
Two tests, one at each end: the service keeps
0as the cleaned search text rather than discarding it, and the repository binds%0%into the fourLIKEconditions rather than emitting no condition. The existing empty-search test stays as it was.Both suites green: 3049 unit, 813 integration.
(Replaces #714 — GitHub never picked up the pushes to that branch.)