From e89478d560ade31f884964607f4c919aa9201931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Thu, 18 Jun 2026 15:09:30 -0300 Subject: [PATCH] Bug 42529: Remove GetAgeRestriction from C4::Circulation GetAgeRestriction is no longer used by any caller. This patch removes it from the exports list and deletes the old test file. Test plan: 1. Run tests without this patch: $ ktd --shell k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/Circulation/AgeRestrictionMarkers.t => SUCCESS: Tests pass! 2. Apply this patch 3. Run: k$ prove t/db_dependent/Circulation.t \ t/db_dependent/Reserves.t \ t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Martin Renvoize Amended-by: Jonathan Druart Removed this from the commit message: "The function body is kept for now as it is not harmful and could be used by third-party code. It is no longer exported." Signed-off-by: Jonathan Druart Signed-off-by: Pedro Amorim --- C4/Circulation.pm | 48 ------------------------- t/Circulation/AgeRestrictionMarkers.t | 50 --------------------------- 2 files changed, 98 deletions(-) delete mode 100755 t/Circulation/AgeRestrictionMarkers.t diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b3e9c77ed8..bfea76ca4c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -4908,54 +4908,6 @@ sub IsItemIssued { return $sth->fetchrow; } -=head2 GetAgeRestriction - - my $ageRestriction = GetAgeRestriction($record_restrictions); - -@PARAM1 the koha.biblioitems.agerestriction value, like K18, PEGI 13, ... -@RETURNS The age restriction age in years. - -=cut - -sub GetAgeRestriction { - my ($record_restrictions) = @_; - 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; - - # Search first occurrence of one of the markers - my @markers = split /\|/, uc($markers); - return unless @markers; - - my $index = 0; - my $restriction_year = 0; - for my $value (@values) { - $index++; - for my $marker (@markers) { - $marker =~ s/^\s+//; #remove leading spaces - $marker =~ s/\s+$//; #remove trailing spaces - if ( $marker eq $value ) { - if ( $index <= $#values ) { - $restriction_year += $values[$index]; - } - last; - } elsif ( $value =~ /^\Q$marker\E(\d+)$/ ) { - - # Perhaps it is something like "K16" (as in Finland) - $restriction_year += $1; - last; - } - } - last if ( $restriction_year > 0 ); - } - - return $restriction_year; -} - =head2 GetPendingOnSiteCheckouts =cut diff --git a/t/Circulation/AgeRestrictionMarkers.t b/t/Circulation/AgeRestrictionMarkers.t deleted file mode 100755 index 6013a79c15..0000000000 --- a/t/Circulation/AgeRestrictionMarkers.t +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl - -# This file is part of Koha. -# -# Copyright 2015 Koha Development Team -# Copyright (C) 2015 Mark Tompsett (Time Zone Shifts) -# -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see . - -use Modern::Perl; - -use DateTime; -use Koha::DateUtils qw( dt_from_string ); -use Test::NoWarnings; -use Test::More tests => 7; -use Test::Warn; - -use t::lib::Mocks; - -use C4::Circulation qw( GetAgeRestriction ); - -t::lib::Mocks::mock_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' ); - -is( C4::Circulation::GetAgeRestriction('FSK 16'), '16', 'FSK 16 returns 16' ); -is( C4::Circulation::GetAgeRestriction('PEGI 16'), '16', 'PEGI 16 returns 16' ); -is( C4::Circulation::GetAgeRestriction('PEGI16'), '16', 'PEGI16 returns 16' ); -is( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' ); -is( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); - -subtest 'No age restriction' => sub { - plan tests => 1; - - warning_is { - C4::Circulation::GetAgeRestriction(); - } - undef, "No warning if GetAgeRestriction is called without restriction"; - -}; -