Bug 33896: Check whether index is defined before string match

This patch checks that $indexes[$i] is defined before testing whether the string matches to remove the logged warning when searching

Test plan:
1) In the intranet, search the catalog from the top search bar
2) Check plack-intranet-error.log
3) There should be a warning "[WARN] Use of uninitialized value within @indexes in string eq"
4) Apply patch
5) restart_all and then re-try the search
6) The warning should no longer appear

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e0c09d230c)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 596d63b426)
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
This commit is contained in:
Matt Blenkinsop 2023-06-05 13:08:47 +00:00 committed by Pedro Amorim
parent a25d826d08
commit 75a1c7966d

View file

@ -461,7 +461,7 @@ my $searcher = Koha::SearchEngine::Search->new(
# If index indicates the value is a barocode, we need to preproccess it before searching
for ( my $i = 0; $i < @operands; $i++ ) {
$operands[$i] = barcodedecode($operands[$i]) if $indexes[$i] eq 'bc';
$operands[$i] = barcodedecode($operands[$i]) if (defined($indexes[$i]) && $indexes[$i] eq 'bc');
}
## I. BUILD THE QUERY