Bug 30155

Summary: We shouldn't calculate get_items_that_can_fill when we don't have any holds
Product: Koha Reporter: Nick Clemens <nick>
Component: CirculationAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi <tomascohen>
Severity: normal    
Priority: P5 - low CC: andrewfh, gmcharlt, kyle.m.hall, kyle, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29087
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.05
Attachments: Bug 30155: Don't get items that can fillholds if there are no holds
Bug 30155: Don't get items that can fillholds if there are no holds
Bug 30155: Don't get items that can fillholds if there are no holds

Description Nick Clemens 2022-02-22 16:53:07 UTC
This breaks the 'Holds to pull' report in 21.05.09 if there are no holds
"Fixed" by bug 3142 in 21.05.11 and master

The problem is essentially that calculation of @bibs_or_items can be empty if no holds are passed, so our SQL Abstract call ends up with an emptpy -or block, which in turn leads to our where beginning with "AND"


DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND `itemlost` = '0' AND `itemnumber` NOT IN ( '156269' ) AND 1=1 AND `notforloa' at line 1 [for Statement "SELECT `me`.`itemnumber`, `me`.`biblionumber`, `me`.`biblioitemnumber`, `me`.`barcode`, `me`.`dateaccessioned`, `me`.`booksellerid`, `me`.`homebranch`, `me`.`price`, `me`.`replacementprice`, `me`.`replacementpricedate`, `me`.`datelastborrowed`, `me`.`datelastseen`, `me`.`stack`, `me`.`notforloan`, `me`.`damaged`, `me`.`damaged_on`, `me`.`itemlost`, `me`.`itemlost_on`, `me`.`withdrawn`, `me`.`withdrawn_on`, `me`.`itemcallnumber`, `me`.`coded_location_qualifier`, `me`.`issues`, `me`.`renewals`, `me`.`reserves`, `me`.`restricted`, `me`.`itemnotes`, `me`.`itemnotes_nonpublic`, `me`.`holdingbranch`, `me`.`timestamp`, `me`.`location`, `me`.`permanent_location`, `me`.`onloan`, `me`.`cn_source`, `me`.`cn_sort`, `me`.`ccode`, `me`.`materials`, `me`.`uri`, `me`.`itype`, `me`.`more_subfields_xml`, `me`.`enumchron`, `me`.`copynumber`, `me`.`stocknumber`, `me`.`new_status`, `me`.`exclude_from_local_holds_priority` FROM `items` `me` WHERE ( (  AND `itemlost` = ? AND `itemnumber` NOT IN ( ? ) AND 1=1 AND `notforloan` = ? AND `onloan` IS NULL AND `withdrawn` = ? ) )" with ParamValues: 0=0, 1=156269, 2=0, 3=0] at /usr/share/koha/lib/Koha/Objects.pm line 145
Comment 1 Nick Clemens 2022-02-22 17:05:09 UTC
Created attachment 131024 [details] [review]
Bug 30155: Don't get items that can fillholds if there are no holds

This makes two changes:
1 - We no longer call get_items_that_can_fill if there are no holds
2 - The subroutine will return an empty Koha::Items object if there are no holds passed
Comment 2 Andrew Fuerste-Henry 2022-03-08 15:57:35 UTC
To test:
- apply patch, restart services
- prove t/db_dependent/Koha/Holds.t
- it passes!
Comment 3 Andrew Fuerste-Henry 2022-03-08 15:58:13 UTC
Created attachment 131485 [details] [review]
Bug 30155: Don't get items that can fillholds if there are no holds

This makes two changes:
1 - We no longer call get_items_that_can_fill if there are no holds
2 - The subroutine will return an empty Koha::Items object if there are no holds passed

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 4 Tomás Cohen Arazi 2022-03-09 14:11:13 UTC
Created attachment 131524 [details] [review]
Bug 30155: Don't get items that can fillholds if there are no holds

This makes two changes:
1 - We no longer call get_items_that_can_fill if there are no holds
2 - The subroutine will return an empty Koha::Items object if there are no holds passed

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 5 Fridolin Somers 2022-03-16 08:31:48 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 6 Kyle M Hall 2022-03-25 13:26:23 UTC
Pushed to 21.11.x for 21.11.05