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 <martin.renvoize@openfifth.co.uk>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 79f23d017a5d6f611f37308cf6cca609a3e1b366)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
da4ae85d61
commit
6daa66b589
|
|
@ -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} ], {%+} ) };
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue