Bug 28365 - (Bug 19873 follow-up) Make it possible to search on value 0
Summary: (Bug 19873 follow-up) Make it possible to search on value 0
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Fridolin Somers
QA Contact: Testopia
URL:
Keywords:
Depends on: 19873
Blocks:
  Show dependency treegraph
 
Reported: 2021-05-17 14:05 UTC by Fridolin Somers
Modified: 2021-11-16 08:12 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.05,20.11.12


Attachments
Bug 28365: Add unit test (1.59 KB, patch)
2021-05-17 14:23 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 28365: (Bug 19873 follow-up) Make it possible to search on value 0 (1.48 KB, patch)
2021-05-17 14:23 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 28365: Add unit test (1.66 KB, patch)
2021-11-02 15:22 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 28365: (Bug 19873 follow-up) Make it possible to search on value 0 (1.54 KB, patch)
2021-11-02 15:22 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2021-05-17 14:05:12 UTC
Bug 19873 fixed search with value 0.
It works in first page but not in other pages.
Comment 1 Fridolin Somers 2021-05-17 14:23:42 UTC
Created attachment 121054 [details] [review]
Bug 28365: Add unit test

Run prove t/db_dependent/Search.t

Without fix you get error :
    #   Failed test 'buildQuery should keep 0 value in query_cgi'
    #   at t/db_dependent/Search.t line 670.
    #          got: 'idx=su%2Cphr'
    #     expected: 'idx=su%2Cphr&q=0'

This patch also adds a test for query_desc in case it is broken in the
future.
Comment 2 Fridolin Somers 2021-05-17 14:23:57 UTC
Created attachment 121055 [details] [review]
Bug 28365: (Bug 19873 follow-up) Make it possible to search on value 0

Bug 19873 fixed search with value 0.
It works in first page but not in other pages.

This patch fixes query_cgi var.

Test plan:
  - create a st-numeric index in zebra conf related to
    a numeric field
    i.e:
    yourindex 1=yourindex 4=109
  - fill a field with 0 in several biblio records,
  - reindex your biblios,
  - search yourindex=0 and go to second page of results,
  - should not work,
  - apply this patch,
  - test again,
  - should work
Comment 3 Martin Renvoize 2021-11-02 15:22:28 UTC
Created attachment 127219 [details] [review]
Bug 28365: Add unit test

Run prove t/db_dependent/Search.t

Without fix you get error :
    #   Failed test 'buildQuery should keep 0 value in query_cgi'
    #   at t/db_dependent/Search.t line 670.
    #          got: 'idx=su%2Cphr'
    #     expected: 'idx=su%2Cphr&q=0'

This patch also adds a test for query_desc in case it is broken in the
future.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2021-11-02 15:22:31 UTC
Created attachment 127220 [details] [review]
Bug 28365: (Bug 19873 follow-up) Make it possible to search on value 0

Bug 19873 fixed search with value 0.
It works in first page but not in other pages.

This patch fixes query_cgi var.

Test plan:
  - create a st-numeric index in zebra conf related to
    a numeric field
    i.e:
    yourindex 1=yourindex 4=109
  - fill a field with 0 in several biblio records,
  - reindex your biblios,
  - search yourindex=0 and go to second page of results,
  - should not work,
  - apply this patch,
  - test again,
  - should work

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2021-11-02 15:23:15 UTC
Super trivial fix, with test coverage and no regressions.

Going straight for QA.. Passed.
Comment 6 Jonathan Druart 2021-11-03 12:32:48 UTC
Not a big deal as the sub is private and only called once, but it would have good to test for the existence of the key, to avoid a warning.
Comment 7 Jonathan Druart 2021-11-03 14:30:47 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 8 Kyle M Hall 2021-11-05 18:09:23 UTC
Pushed to 21.05.x for 21.05.05
Comment 9 Fridolin Somers 2021-11-11 01:46:43 UTC
Pushed to 20.11.x for 20.11.12
Comment 10 Victor Grousset/tuxayo 2021-11-16 08:12:51 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.