Bugzilla – Attachment 114296 Details for
Bug 27160
Fatal error when ReservesMaxPickUpDelay is empty and item with hold is checked in
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27160: Prevent 500 when checking an item in if ReservesMaxPickUpDelay has been deleted
Bug-27160-Prevent-500-when-checking-an-item-in-if-.patch (text/plain), 3.22 KB, created by
Jonathan Druart
on 2020-12-10 08:52:42 UTC
(
hide
)
Description:
Bug 27160: Prevent 500 when checking an item in if ReservesMaxPickUpDelay has been deleted
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-12-10 08:52:42 UTC
Size:
3.22 KB
patch
obsolete
>From 821f9d813755412ace93411cca9e5fcad9053da3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 10 Dec 2020 09:50:17 +0100 >Subject: [PATCH] Bug 27160: Prevent 500 when checking an item in if > ReservesMaxPickUpDelay has been deleted > >We could default to 0 if the syspref does not exist. >However I don't think we should deal with that kind of issue, sysprefs >must be in DB. > >Test plan: >Delete ReservesMaxPickUpDelay from the DB >Place an item on hold >Check it in >Confirm the hold >Without this patch you get: >"Validation failed for type named Defined declared in package Specio::Library::Builtins" (see the relevant part of the trace at comment 3) >--- > Koha/Hold.pm | 2 +- > t/db_dependent/Koha/Holds.t | 41 ++++++++++++++++++++++++++++++++++++- > 2 files changed, 41 insertions(+), 2 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 7754691238..176b7bdf7f 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -191,7 +191,7 @@ sub set_waiting { > $requested_expiration = dt_from_string($self->expirationdate); > } > >- my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); >+ my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay") || 0; > my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); > > my $expirationdate = $today->clone; >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index 538e7119de..bd5e778390 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -19,12 +19,13 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::Warn; > > use C4::Reserves; > use Koha::AuthorisedValueCategory; > use Koha::Database; >+use Koha::DateUtils qw( dt_from_string ); > use Koha::Holds; > > use t::lib::Mocks; >@@ -408,6 +409,44 @@ subtest 'Desks' => sub { > > }; > >+subtest 'set_waiting' => sub { >+ >+ plan tests => 1; >+ >+ subtest 'ReservesMaxPickUpDelay got removed' => sub { >+ >+ plan tests => 1; >+ >+ t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', undef); >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $item = $builder->build_sample_item({ library => $library->branchcode }); >+ my $manager = $builder->build_object( { class => "Koha::Patrons" } ); >+ t::lib::Mocks::mock_userenv( { patron => $manager, branchcode => $manager->branchcode } ); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->branchcode, } >+ } >+ ); >+ >+ my $reserve_id = C4::Reserves::AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ priority => 1, >+ itemnumber => $item->itemnumber, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ $hold->set_waiting; >+ is( $hold->waitingdate, dt_from_string->ymd, 'If ReservesMaxPickUpDelay does not exist in DB, we should default to 0' ); >+ }; >+}; >+ > $schema->storage->txn_rollback; > > 1; >-- >2.20.1
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 27160
: 114296