Bug 13022 - Hardcoded limit causes records with more than 20 items to show inaccurate...
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 2 Oct 2014 13:19:21 +0000 (09:19 -0400)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Thu, 31 Dec 2015 18:11:21 +0000 (18:11 +0000)
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

Signed-off-by: Andreas Hedström Mace <andreas.hedstrom.mace@sub.su.se>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
C4/Search.pm
installer/data/mysql/atomicupdate/bug_13022.sql [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref

index e217f60..a23fe13 100644 (file)
@@ -2095,7 +2095,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/atomicupdate/bug_13022.sql b/installer/data/mysql/atomicupdate/bug_13022.sql
new file mode 100644 (file)
index 0000000..88d5a13
--- /dev/null
@@ -0,0 +1 @@
+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');
index 293ba2d..999f5c5 100644 (file)
@@ -223,6 +223,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'),
 ('MembershipExpiryDaysNotice',NULL,'Send an account expiration notice that a patron\'s card is about to expire after',NULL,'Integer'),
 ('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'),
 ('minPasswordLength','3',NULL,'Specify the minimum length of a patron/staff password','free'),
index 8b04d39..a7c39bf 100644 (file)
@@ -148,6 +148,11 @@ Searching:
             - pref: numSearchResults
               class: integer
             - results per page in the staff client.
+        -
+            - For records with many items, only check the availability status for the first
+            - pref: MaxSearchResultsItemsPerRecordStatusCheck
+              class: integer
+            - items. If a record has more than this number of items, they availability statuses may be incorrect in the search results, but will be correct in the record details.
         -
             - By default, sort search results in the OPAC by
             - pref: OPACdefaultSortField