Bug 19691

Summary: Enforce OPAC SEARCH LIMIT server-side
Product: Koha Reporter: David Bourgault <david.bourgault>
Component: SearchingAssignee: David Bourgault <david.bourgault>
Status: Patch doesn't apply --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: alexbuckley, david.bourgault, fridolin.somers
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 19691 - Move code to opac-search.pl

Description David Bourgault 2017-11-24 15:04:07 UTC
Current behavior of the OPAC_SEARCH_LIMIT variable (set in httpd.conf) is to add a hidden HTML input in masthead.inc.

This works, but makes it easy to override the limit by altering the URL.
Comment 1 David Bourgault 2017-11-24 15:21:20 UTC
Created attachment 69335 [details] [review]
Bug 19691 - Move code to opac-search.pl

Removes the hidden input from masthead.inc, and adds a line to opac-search.pl to enforce the limit.

Test plan:
Before:
0) Set OPAC_SEARCH_LIMIT and OPAC_LIMIT_OVERRIDE to valid values in koha-httpd.conf (they should be commented)
1) Reload apache
2) Perform a search in the OPAC. You'll see the limit you specified appended to the URL and reflected in the results.
3) Manually remove the limit from the URL and load the page; the search results will not reflect the limit.

After:
0) With the same apache config
1) Perform a search from the OPAC. The limit will not show up in the URL, but will be reflected in the search results. There should be no way of circumventing the limit.
Comment 2 Alex Buckley 2018-10-29 22:58:33 UTC
Hi there

Can you please rebase this as it is not applying cleanly on master as the below output shows:

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 19691 - Move code to opac-search.pl
Using index info to reconstruct a base tree...
M	koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
M	opac/opac-search.pl
Falling back to patching base and 3-way merge...
Auto-merging opac/opac-search.pl
Auto-merging koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
CONFLICT (content): Merge conflict in koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
Failed to merge in the changes.
Patch failed at 0001 Bug 19691 - Move code to opac-search.pl
The copy of the patch that failed is found in:
   /home/vagrant/kohaclone/.git/rebase-apply/patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-19691---Move-code-to-opac-searchpl-BrIj3i.patch

Cheers,
Alex
Comment 3 Fridolin Somers 2020-11-10 10:23:53 UTC
In this case remove also code from C4::Auth
  opac_search_limit                     => $opac_search_limit,