From 6daa66b589b511318196799aa0e9af749c59448e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 1 Jul 2026 08:18:13 +0100 Subject: [PATCH] Bug 30233: (follow-up) Log a warning when _apply_substitution discards a bad pattern When eval { qr/$pattern/ } fails (e.g. the admin-configured s/// contains an invalid regex), _apply_substitution previously returned silently with no indication of why the rule was skipped. Add a Koha::Logger warn so the failure appears in the log and is diagnosable without a debugger. Signed-off-by: Martin Renvoize Signed-off-by: Baptiste Wojtkowski Signed-off-by: Lucas Gass (cherry picked from commit 79f23d017a5d6f611f37308cf6cca609a3e1b366) Signed-off-by: Lucas Gass --- C4/ClassSplitRoutine/RegEx.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/C4/ClassSplitRoutine/RegEx.pm b/C4/ClassSplitRoutine/RegEx.pm index b2dfd2d385..1369727bcc 100644 --- a/C4/ClassSplitRoutine/RegEx.pm +++ b/C4/ClassSplitRoutine/RegEx.pm @@ -19,6 +19,7 @@ package C4::ClassSplitRoutine::RegEx; use Modern::Perl; +use Koha::Logger; use Koha::Regex::Replacement; =head1 NAME @@ -83,7 +84,10 @@ sub _apply_substitution { my $ci = $flags =~ /i/ ? '(?i)' : ''; my $compiled = eval { qr/$ci$pattern/ }; - return unless defined $compiled; + unless ( defined $compiled ) { + Koha::Logger->get->warn("C4::ClassSplitRoutine::RegEx: failed to compile pattern [$pattern]: $@"); + return; + } my $expand = sub { Koha::Regex::Replacement::expand_template( $replacement, [ @{^CAPTURE} ], {%+} ) };