Bug 28365

Summary: (Bug 19873 follow-up) Make it possible to search on value 0
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: SearchingAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: dcook, jonathan.druart, kyle, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28526
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.05,20.11.12
Circulation function:
Bug Depends on: 19873    
Bug Blocks:    
Attachments: Bug 28365: Add unit test
Bug 28365: (Bug 19873 follow-up) Make it possible to search on value 0
Bug 28365: Add unit test
Bug 28365: (Bug 19873 follow-up) Make it possible to search on value 0

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 (ashimema) 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 (ashimema) 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 (ashimema) 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 (khall) 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.