Bugzilla – Attachment 96793 Details for
Bug 24331
Internal server error when placing hold on item if itemtype undefined
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24331: Don't die on items with no type
Bug-24331-Dont-die-on-items-with-no-type.patch (text/plain), 2.68 KB, created by
Nick Clemens (kidclamp)
on 2020-01-03 13:30:49 UTC
(
hide
)
Description:
Bug 24331: Don't die on items with no type
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-01-03 13:30:49 UTC
Size:
2.68 KB
patch
obsolete
>From b9782d9db659d9a30d89c49469d7f80032618261 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 3 Jan 2020 13:27:16 +0000 >Subject: [PATCH] Bug 24331: Don't die on items with no type > >To test: >1 - Find or create an item with no itemtype set >2 - Attempt to place a hold >3 - INternal server error >4 - Apply patch >5 - Repeat >6 - No error >7 - Set the items itemtype to an itemtype marked not for loan >8 - Set circ rules to allow holds on this itemtype >9 - Attempt to place hold, item is not holdable >10 - Remove not for loan from itemtype >11 - Item is holdable >--- > C4/Reserves.pm | 4 ++-- > t/db_dependent/Reserves.t | 10 +++++++++- > 2 files changed, 11 insertions(+), 3 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 7a3785724a..c508b44294 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1195,8 +1195,8 @@ sub IsAvailableForItemLevelRequest { > # FIXME - a lot of places in the code do this > # or something similar - need to be > # consolidated >- my $itemtype = $item->effective_itemtype; >- my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan; >+ my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); >+ my $notforloan_per_itemtype = defined $itemtype ? $itemtype->notforloan : 0; > > return 0 if > $notforloan_per_itemtype || >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 618f0598c9..2c8ed070c4 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,9 +17,10 @@ > > use Modern::Perl; > >-use Test::More tests => 62; >+use Test::More tests => 64; > use Test::MockModule; > use Test::Warn; >+use Test::Exception; > > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -533,6 +534,13 @@ $item = Koha::Items->find($itemnumber); > > ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $patron), "Reserving a book on item level" ); > >+# Tests for items not for loan status, bug 24331 >+my $item_no_type = $builder->build_sample_item({ itype => undef }); >+lives_ok{ C4::Reserves::IsAvailableForItemLevelRequest($item_no_type, $patron) } "Reserving a book on item level with no itemtype"; >+my $itemtype_notforloan = $builder->build_object({ class => 'Koha::ItemTypes', value => { notforloan => 1 } })->itemtype; >+my $item_notforloan = $builder->build_sample_item({ itype => $itemtype_notforloan }); >+is( C4::Reserves::IsAvailableForItemLevelRequest($item_notforloan, $patron), 0, "Item not available if itemtype notforloan" ); >+ > my $pickup_branch = $builder->build({ source => 'Branch' })->{ branchcode }; > t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); > t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24331
:
96793
|
97584