Bug 24168

Summary: Errors with use of CanItemBeReserved return value
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: Hold requestsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: critical    
Priority: P5 - low CC: 1joynelson, arthur.suzuki, gmcharlt, jonathan.druart, kyle, lucas, m.de.rooy, martin.renvoize, tomascohen
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:
20.05.00, 19.11.01
Bug Depends on: 15524, 23116    
Bug Blocks:    
Attachments: Bug 24168: (bug 23116 follow-up) AllowHoldPolicyOverride allows a librarian to almost place a hold on an item already on hold
Bug 24168: (bug 23116 follow-up) AllowHoldPolicyOverride allows a librarian to almost place a hold on an item already on hold

Description Fridolin Somers 2019-12-04 10:56:34 UTC
Bug 15524 changed CanItemBeReserved to return a hashref with status inside.

Looks like But 23116 was intruced with previous behavior.

So now there a uses of CanItemBeReserved return value as a string :
if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) {

use git grep can_item_be_reserved.
Comment 1 Fridolin Somers 2019-12-04 11:06:01 UTC
Also impact on Bug 22330
Comment 2 Fridolin Somers 2019-12-04 11:27:16 UTC
(In reply to Fridolin SOMERS from comment #1)
> Also impact on Bug 22330

Oups sorry no its correct : 
  my $canitembereserved = C4::Reserves::CanItemBeReserved( $borrowernumber, $itemnumber, $branch )->{status};
Comment 3 Jonathan Druart 2019-12-04 15:07:54 UTC
Created attachment 95994 [details] [review]
Bug 24168: (bug 23116 follow-up) AllowHoldPolicyOverride allows a librarian to almost place a hold on an item already on hold

This patch actually fixes the issue described on bug 23116.

Test plan:
See bug 23116.
Comment 4 Marcel de Rooy 2019-12-06 10:20:10 UTC
Hmm. I actually do not see the difference this patch makes. Looks to me if nothing really changes here.
Before we tested $var->{status} eq 'OK' and now we put status into $var and test $var eq 'OK'.
Where is the bug that we should solve ?
Comment 5 Jonathan Druart 2019-12-06 13:10:47 UTC
Take a look at the file and search for "can_item_be_reserved".
There is another occurrence.
Comment 6 Marcel de Rooy 2019-12-09 12:55:12 UTC
Created attachment 96099 [details] [review]
Bug 24168: (bug 23116 follow-up) AllowHoldPolicyOverride allows a librarian to almost place a hold on an item already on hold

This patch actually fixes the issue described on bug 23116.

Test plan:
See bug 23116.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
See also comment5. Important to note that the later comparison with
itemAlreadyOnHold assumes that the variable is a string.
Comment 7 Marcel de Rooy 2019-12-09 12:56:08 UTC
(In reply to Jonathan Druart from comment #5)
> Take a look at the file and search for "can_item_be_reserved".
> There is another occurrence.

OK Thats the point.
Passed QA
Comment 8 Martin Renvoize 2019-12-09 14:19:44 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 9 Joy Nelson 2019-12-10 20:16:30 UTC
Pushed to stable 19.11.01
Comment 10 Lucas Gass 2019-12-20 15:08:52 UTC
backported to 19.05.x for 19.05.06