From 4c89fd3989990beaef8056c946d1dd642d0042bf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 13 Jan 2020 15:35:57 +0100 Subject: [PATCH] Bug 24361: Remove warning from GetAgeRestriction Use of uninitialized value $record_restrictions in uc at /kohadevbox/koha/C4/Circulation.pm line 3981 Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 1 + t/Circulation/AgeRestrictionMarkers.t | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index d2506275e3..c3629c2472 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3977,6 +3977,7 @@ sub GetAgeRestriction { my ($record_restrictions, $borrower) = @_; my $markers = C4::Context->preference('AgeRestrictionMarker'); + return unless $record_restrictions; # Split $record_restrictions to something like FSK 16 or PEGI 6 my @values = split ' ', uc($record_restrictions); return unless @values; diff --git a/t/Circulation/AgeRestrictionMarkers.t b/t/Circulation/AgeRestrictionMarkers.t index 49c1d14444..e6d335ee23 100644 --- a/t/Circulation/AgeRestrictionMarkers.t +++ b/t/Circulation/AgeRestrictionMarkers.t @@ -21,7 +21,8 @@ use Modern::Perl; use DateTime; -use Test::More tests => 7; +use Test::More tests => 8; +use Test::Warn; use t::lib::Mocks; @@ -64,6 +65,16 @@ subtest 'Patron tests - 15 years old (Time Zone shifts)' => sub { } }; +subtest 'No age restriction' => sub { + plan tests => 1; + + warning_is { + C4::Circulation::GetAgeRestriction(); + } + undef, "No warning if GetAgeRestriction is called without restriction"; + +}; + # The Patron tests sub TestPatron { my ($borrower,$offset) = @_; -- 2.39.5