View | Details | Raw Unified | Return to bug 22690
Collapse All | Expand All

(-)a/Koha/Items.pm (-4 / +7 lines)
Lines 121-132 Move items to a given biblio. Link Here
121
sub move_to_biblio {
121
sub move_to_biblio {
122
    my ( $self, $to_biblio ) = @_;
122
    my ( $self, $to_biblio ) = @_;
123
123
124
    while (my $item = $self->next()) {
124
    my $biblionumbers = { $to_biblio->biblionumber => 1 };
125
        $item->move_to_biblio($to_biblio, { skip_record_index => 1 });
125
    while ( my $item = $self->next() ) {
126
        $biblionumbers->{ $item->biblionumber } = 1;
127
        $item->move_to_biblio( $to_biblio, { skip_record_index => 1 } );
126
    }
128
    }
127
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
129
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
128
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" );
130
    for my $biblionumber ( keys %{$biblionumbers} ) {
129
    $indexer->index_records( $to_biblio->biblionumber, "specialUpdate", "biblioserver" );
131
        $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
132
    }
130
}
133
}
131
134
132
135
(-)a/t/db_dependent/Koha/SearchEngine/Indexer.t (-9 / +14 lines)
Lines 61-67 subtest 'Test indexer object creation' => sub { Link Here
61
};
61
};
62
62
63
subtest 'Test indexer calls' => sub {
63
subtest 'Test indexer calls' => sub {
64
    plan tests => 46;
64
    plan tests => 48;
65
65
66
    my @engines = ('Zebra');
66
    my @engines = ('Zebra');
67
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
67
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
Lines 105-115 subtest 'Test indexer calls' => sub { Link Here
105
105
106
        my $biblio;
106
        my $biblio;
107
        my $biblio2;
107
        my $biblio2;
108
        my $biblio3;
108
        warnings_are{
109
        warnings_are{
109
            $biblio = $builder->build_sample_biblio();
110
            $biblio = $builder->build_sample_biblio();
110
            $biblio2 = $builder->build_sample_biblio();
111
            $biblio2 = $builder->build_sample_biblio();
111
        } [$engine,'C4::Biblio',$engine,'C4::Biblio'], "index_records is called for $engine when adding a biblio (ModBiblioMarc)";
112
            $biblio3 = $builder->build_sample_biblio();
112
113
        } [$engine,'C4::Biblio',$engine,'C4::Biblio',$engine,'C4::Biblio'], "index_records is called for $engine when adding a biblio (ModBiblioMarc)";
113
114
114
        my $item;
115
        my $item;
115
        my $item2;
116
        my $item2;
Lines 132-139 subtest 'Test indexer calls' => sub { Link Here
132
            });
133
            });
133
            $item3 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
134
            $item3 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
134
            $item4 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
135
            $item4 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
135
            $item5 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
136
            $item5 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber});
136
            $item6 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
137
            $item6 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber});
137
        } [$engine,"Koha::Item",
138
        } [$engine,"Koha::Item",
138
           $engine,"Koha::Item",
139
           $engine,"Koha::Item",
139
           $engine,"Koha::Item",
140
           $engine,"Koha::Item",
Lines 185-191 subtest 'Test indexer calls' => sub { Link Here
185
186
186
        warnings_are{
187
        warnings_are{
187
            $biblio->items->move_to_biblio($biblio2);
188
            $biblio->items->move_to_biblio($biblio2);
188
        } [$engine,"Koha::Biblio",$engine,"Koha::Biblio"], "index_records is called for both biblios for $engine when adopting items (Biblio->items->move_to_biblio(Biblio)";
189
        } [$engine,"Koha::Items",$engine,"Koha::Items"], "index_records is called for from and to biblios for $engine when adopting items (Biblio->items->move_to_biblio(Biblio)";
190
191
        my $items = Koha::Items->search({ itemnumber => [ $item2->itemnumber, $item5->itemnumber, $item6->itemnumber ] });
192
        warnings_are{
193
            $items->move_to_biblio($biblio);
194
        } [$engine,"Koha::Items",$engine,"Koha::Items",$engine,"Koha::Items"], "index_records is called for all from and to biblios for $engine when adopting items (Items->move_to_biblio(Biblio)";
189
195
190
        $builder->build({
196
        $builder->build({
191
            source => 'Issue',
197
            source => 'Issue',
Lines 231-240 subtest 'Test indexer calls' => sub { Link Here
231
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed";
237
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed";
232
238
233
        warnings_are{
239
        warnings_are{
234
            DelBiblio( $biblio->biblionumber );
240
            DelBiblio( $biblio3->biblionumber );
235
        } [$engine, "C4::Biblio"], "index_records is called for $engine when calling DelBiblio";
241
        } [$engine, "C4::Biblio"], "index_records is called for $engine when calling DelBiblio";
236
        warnings_are{
242
        warnings_are{
237
            DelBiblio( $biblio->biblionumber, { skip_record_index =>1 });
243
            DelBiblio( $biblio3->biblionumber, { skip_record_index =>1 });
238
        } undef, "index_records is not called for $engine when calling DelBiblio if skip_record_index passed";
244
        } undef, "index_records is not called for $engine when calling DelBiblio if skip_record_index passed";
239
245
240
    }
246
    }
241
- 

Return to bug 22690