It's possible to search prefs using a regex.
But it the regex is not correctly written, the app explodes.
We should provide a fallback.
Test plan:
0/ Does not apply the patch
1/ Search for sysprefs with "notes.*", note the number of results
2/ Search for *notes*, boom
3/ Apply the patch
4/ Repeat 1 and confirm you get the same number of results
5/ Repeat 2 and confirm you don't get the error anymore
NOTE: As noted on comment #4, the kaboom is because of the
leading * and not the following *, because 's*' is a valid
regular expression, while '*n' is not.
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
sub matches {
my ( $text, $terms ) = @_;
- if ( $text ) { return !grep( { $text !~ /$_/i } @$terms ); }
+ if ( $text ) {
+ return !grep(
+ {
+ my $re = eval{qr|$_|i};
+ $re = qr|\Q$_\E| if $@;
+ $text !~ m|$re|;
+ } @$terms
+ )
+ }
}
my $dbh = C4::Context->dbh;