From 502b43306512ffe0b71221d71fc1ec3bea5b6f72 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 21 Apr 2021 11:53:53 +0200 Subject: [PATCH] Bug 23271: Prevent crash if called without parameters Can't use an undefined value as a HASH reference at /kohadevbox/koha/Koha/Objects/Limit/Library.pm line 87. --- Koha/Objects/Limit/Library.pm | 1 + t/db_dependent/Koha/Patron/Attribute/Types.t | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Koha/Objects/Limit/Library.pm b/Koha/Objects/Limit/Library.pm index 2f9d2d2ec6..f16fca6a3d 100644 --- a/Koha/Objects/Limit/Library.pm +++ b/Koha/Objects/Limit/Library.pm @@ -71,6 +71,7 @@ sub search_with_library_limits { ] }; + $params //= {}; $attributes //= {}; if ( exists $attributes->{join} ) { if ( ref $attributes->{join} eq 'ARRAY' ) { diff --git a/t/db_dependent/Koha/Patron/Attribute/Types.t b/t/db_dependent/Koha/Patron/Attribute/Types.t index 3df82bcfba..c7bb0d2fbc 100755 --- a/t/db_dependent/Koha/Patron/Attribute/Types.t +++ b/t/db_dependent/Koha/Patron/Attribute/Types.t @@ -388,7 +388,7 @@ subtest 'replace_library_limits() tests' => sub { subtest 'search_with_library_limits() tests' => sub { - plan tests => 5; + plan tests => 6; $schema->storage->txn_begin; @@ -427,6 +427,10 @@ subtest 'search_with_library_limits() tests' => sub { is( $results->count, 3, '3 attribute types are available with no library passed' ); + $results = Koha::Patron::Attribute::Types->search_with_library_limits(); + + is( $results->count, 3, 'No crash if no params passed' ); + $schema->storage->txn_rollback; }; -- 2.20.1