Bug 24361: Remove warning from GetAgeRestriction
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 13 Jan 2020 14:35:57 +0000 (15:35 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 13 Jan 2020 14:48:36 +0000 (14:48 +0000)
Use of uninitialized value $record_restrictions in uc at /kohadevbox/koha/C4/Circulation.pm line 3981

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
C4/Circulation.pm
t/Circulation/AgeRestrictionMarkers.t

index d250627..c3629c2 100644 (file)
@@ -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;
index 49c1d14..e6d335e 100644 (file)
@@ -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) = @_;