From 6a941e5b86f36256327d3a890c5037145cb935f7 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. Signed-off-by: Jonathan Druart --- 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.39.5