Bug 29087 - Holds to pull list can crash with a SQL::Abstract puke
Summary: Holds to pull list can crash with a SQL::Abstract puke
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Hold requests (show other bugs)
Version: master
Hardware: All All
: P5 - low major with 1 vote (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 3142
Blocks:
  Show dependency treegraph
 
Reported: 2021-09-22 21:16 UTC by Galen Charlton
Modified: 2022-04-05 11:13 UTC (History)
8 users (show)

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


Attachments
Bug 29087: Prevent filter_by_for_hold to crash if default holdallowed is not_allowed (3.47 KB, patch)
2021-11-19 12:28 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Galen Charlton 2021-09-22 21:16:14 UTC
Opening the holds to pull list page can crash with the following logged error:

  SQL::Abstract::puke(): [SQL::Abstract::__ANON__] Fatal: SQL::Abstract before v1.75 used to generate incorrect SQL when the -NOT IN operator was given an undef-containing list: !!!AUDIT YOUR CODE AND DATA!!! (the upcoming Data::Query-based version of SQL::Abstract will emit the logically correct SQL instead of raising this exception) at /usr/share/koha/lib/Koha/Objects.pm line 145

I've traced this to Koha::Holds->get_items_that_can_fill(). Among other things, this routine fetches a list of item types that cannot fill holds, i.e., cases where the 'holdallowed' rule value is 'not_allowed'.

However, if your default rule is to not allow holds, the @hold_not_allowed_itypes list will end up including an entry whose value is undef. When passed to the item query, doing the -not_in filter on itype will result in the crash listed above.

A quick fix might be to filter out undef from that list. That will fix the crash, but could lead to incorrect results if the default policy is to deny holds for all item types except for ones that are going to be specifically permitted.
Comment 1 Jonathan Druart 2021-11-19 12:28:00 UTC
Created attachment 127859 [details] [review]
Bug 29087: Prevent filter_by_for_hold to crash if default holdallowed is not_allowed
Comment 2 Jonathan Druart 2021-11-19 12:29:01 UTC
This seems to be the way to go, but I don't think it's ready for integration. We should have the logic moved to Koha::ItemTypes and add test coverage. Will try and come back to this later.
Comment 3 Jonathan Druart 2021-11-19 12:31:02 UTC
Galen, thanks for reporting this bug!
Are you seeing this in master or stable?
Comment 4 Ashley Johnson 2021-12-23 01:05:43 UTC
Our library system is seeing this bug as well. Had a lot of staff reporting the error message to me today.
Comment 5 Liz Rea 2022-03-25 17:53:13 UTC
We have some libraries seeing this now as well, the rule mentioned here doesn't seem to be the culprit, but the error is the same.
Comment 6 Jonathan Druart 2022-03-25 18:42:38 UTC
Which version? Did you try the patch?