Bug 29888 - ->search_limited logic breaks searches
Summary: ->search_limited logic breaks searches
Status: ASSIGNED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-14 18:09 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2024-06-11 11:20 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2022-01-14 18:09:00 UTC
When writing unit tests for bug 29886, in which I was moving bug 23991 addtion of Koha::Suggestions->search_limited I noticed a problem with how the query is amended to deal with limitations: instead of relying on chained searches, it tries (badly) to tweak the passed parameters.

This line was disturbing to me:

    $params->{branchcode} = { -or => [ $userenv->{branch}, '' ] };

it means any query on branchcode will be overwritten! (another bug could be filed to discuss that '' in there).

I propose to revisit the current ->search_limited implementations, and fix them:
$ git grep 'sub search_limited'
Koha/ArticleRequests.pm:sub search_limited {
Koha/Patron/Discharge.pm:sub search_limited {
Koha/Patrons.pm:sub search_limited {
Koha/Reviews.pm:sub search_limited {
Comment 1 Martin Renvoize (ashimema) 2024-06-11 11:20:38 UTC
Is this one still relevant Tomas?