Browse Source

Bug 27344: Fix call to update_index with invalid ids

Can't use an undefined value as an ARRAY reference at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/Indexer.pm line 121.

Caught that when working on follow-up bug reports.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
22.05.x
Jonathan Druart 2 years ago
committed by Fridolin Somers
parent
commit
04c0413352
  1. 2
      Koha/SearchEngine/Elasticsearch/Indexer.pm
  2. 18
      t/db_dependent/Koha/SearchEngine/Elasticsearch/Indexer.t

2
Koha/SearchEngine/Elasticsearch/Indexer.pm

@ -100,7 +100,7 @@ Arrayref of C<MARC::Record>s.
sub update_index {
my ($self, $record_ids, $records) = @_;
my $index_record_ids;
my $index_record_ids = [];
unless ( $records && @$records ) {
for my $record_id ( sort { $a <=> $b } @$record_ids ) {

18
t/db_dependent/Koha/SearchEngine/Elasticsearch/Indexer.t

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 3;
use Test::More tests => 4;
use Test::MockModule;
use Test::Warn;
use t::lib::Mocks;
@ -120,6 +120,22 @@ subtest 'index_records() tests' => sub {
}
"Update background " . $biblio->biblionumber,
"When passing id only to index_records the marc record is fetched and passed through to update_index";
};
subtest 'update_index' => sub {
plan tests => 1;
my $biblio = $builder->build_sample_biblio;
my $biblionumber = $biblio->biblionumber;
$biblio->delete;
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new({ 'index' => 'biblios' });
warning_is {
$indexer->update_index([$biblionumber]);
} "", "update_index called with deleted biblionumber should not crash";
};
}

Loading…
Cancel
Save