From 1a6679fa3ef45715a607cba9be9f19a7df435039 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 2 Oct 2014 09:19:21 -0400 Subject: [PATCH] Bug 13022 - Hardcoded limit causes records with more than 20 items to show inaccurate statuses If a record has more than 20 items, all the items over 20 will show as available on the search results even if they are not! This is a hard coded limit in the Search module. This number should be configurable. Test Plan: 1) Create a record with more than 20 items 2) Set all the items to waiting holds or in transit 3) Search for results that will include that item 4) Note some say they are available even though they are not 5) Apply this patch 6) Run updatedatabase.pl 7) Set the new system preference MaxSearchResultsItemsPerRecordStatusCheck to a number larger than the number of items on your record 8) Re-run the search 9) Note that the hold and transit statuses for the items are now correct --- C4/Search.pm | 2 +- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../en/modules/admin/preferences/searching.pref | 5 +++++ 4 files changed, 14 insertions(+), 1 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 932d04b..7d7ba4d 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2000,7 +2000,7 @@ sub searchResults { || $item->{itemlost} || $item->{damaged} || $item->{notforloan} - || $items_count > 20) { + || $items_count > C4::Context->preference('MaxSearchResultsItemsPerRecordStatusCheck') ) { # A couple heuristics to limit how many times # we query the database for item transfer information, sacrificing diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index b06b163..a037c21 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -192,6 +192,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), +('MaxSearchResultsItemsPerRecordStatusCheck','20','','Max number of items per record for which to check transit and hold status','Integer'), ('minPasswordLength','3',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6ea5911..651fd0b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8781,6 +8781,13 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion ="3.17.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('MaxSearchResultsItemsPerRecordStatusCheck','20','Max number of items per record for which to check transit and hold status','','Integer');"); + print "Upgrade to $DBversion done (Bug 9761: Add ConfirmFutureHolds pref)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index eee5cc9..e260d33 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -149,6 +149,11 @@ Searching: class: integer - results per page in the staff client. - + - For records with many items, only check the hold and transit status for the first + - pref: MaxSearchResultsItemsPerRecordStatusCheck + class: integer + - items. + - - By default, sort search results in the OPAC by - pref: OPACdefaultSortField default: relevance -- 1.7.2.5