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

(-)a/C4/Circulation.pm (-3 / +3 lines)
Lines 3721-3733 sub ReturnLostItem{ Link Here
3721
  LostItem( $itemnumber, $mark_lost_from, $force_mark_returned, [$params] );
3721
  LostItem( $itemnumber, $mark_lost_from, $force_mark_returned, [$params] );
3722
3722
3723
The final optional parameter, C<$params>, expected to contain
3723
The final optional parameter, C<$params>, expected to contain
3724
'skip_modzebra_update' key, which relayed down to Koha::Item/store,
3724
'skip_record_index' key, which relayed down to Koha::Item/store,
3725
there it prevents calling of ModZebra index_records,
3725
there it prevents calling of ModZebra index_records,
3726
which takes most of the time in batch adds/deletes: index_records better
3726
which takes most of the time in batch adds/deletes: index_records better
3727
to be called later in C<additem.pl> after the whole loop.
3727
to be called later in C<additem.pl> after the whole loop.
3728
3728
3729
$params:
3729
$params:
3730
    skip_modzebra_update => 1|0
3730
    skip_record_index => 1|0
3731
3731
3732
=cut
3732
=cut
3733
3733
Lines 3783-3789 sub LostItem{ Link Here
3783
3783
3784
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3784
    #When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch)
3785
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3785
    if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) {
3786
        Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store({ skip_modzebra_update => $params->{skip_modzebra_update} });
3786
        Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store({ skip_record_index => $params->{skip_record_index} });
3787
    }
3787
    }
3788
    my $transferdeleted = DeleteTransfer($itemnumber);
3788
    my $transferdeleted = DeleteTransfer($itemnumber);
3789
}
3789
}
(-)a/C4/Items.pm (-6 / +6 lines)
Lines 144-156 Given a MARC::Record object containing an embedded item Link Here
144
record and a biblionumber, create a new item record.
144
record and a biblionumber, create a new item record.
145
145
146
The final optional parameter, C<$params>, expected to contain
146
The final optional parameter, C<$params>, expected to contain
147
'skip_modzebra_update' key, which relayed down to Koha::Item/store,
147
'skip_record_index' key, which relayed down to Koha::Item/store,
148
there it prevents calling of index_records,
148
there it prevents calling of index_records,
149
which takes most of the time in batch adds/deletes: index_records
149
which takes most of the time in batch adds/deletes: index_records
150
to be called later in C<additem.pl> after the whole loop.
150
to be called later in C<additem.pl> after the whole loop.
151
151
152
$params:
152
$params:
153
    skip_modzebra_update => 1|0
153
    skip_record_index => 1|0
154
154
155
=cut
155
=cut
156
156
Lines 174-180 sub AddItemFromMarc { Link Here
174
    $item_values->{biblionumber} = $biblionumber;
174
    $item_values->{biblionumber} = $biblionumber;
175
    $item_values->{cn_source} = delete $item_values->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
175
    $item_values->{cn_source} = delete $item_values->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
176
    $item_values->{cn_sort}   = delete $item_values->{'items.cn_sort'};   # Because of C4::Biblio::_disambiguate
176
    $item_values->{cn_sort}   = delete $item_values->{'items.cn_sort'};   # Because of C4::Biblio::_disambiguate
177
    my $item = Koha::Item->new( $item_values )->store({ skip_modzebra_update => $params->{skip_modzebra_update} });
177
    my $item = Koha::Item->new( $item_values )->store({ skip_record_index => $params->{skip_record_index} });
178
    return ( $item->biblionumber, $item->biblioitemnumber, $item->itemnumber );
178
    return ( $item->biblionumber, $item->biblioitemnumber, $item->itemnumber );
179
}
179
}
180
180
Lines 287-299 sub AddItemBatchFromMarc { Link Here
287
my $item = ModItemFromMarc($item_marc, $biblionumber, $itemnumber[, $params]);
287
my $item = ModItemFromMarc($item_marc, $biblionumber, $itemnumber[, $params]);
288
288
289
The final optional parameter, C<$params>, expected to contain
289
The final optional parameter, C<$params>, expected to contain
290
'skip_modzebra_update' key, which relayed down to Koha::Item/store,
290
'skip_record_index' key, which relayed down to Koha::Item/store,
291
there it prevents calling of index_records,
291
there it prevents calling of index_records,
292
which takes most of the time in batch adds/deletes: index_records better
292
which takes most of the time in batch adds/deletes: index_records better
293
to be called later in C<additem.pl> after the whole loop.
293
to be called later in C<additem.pl> after the whole loop.
294
294
295
$params:
295
$params:
296
    skip_modzebra_update => 1|0
296
    skip_record_index => 1|0
297
297
298
=cut
298
=cut
299
299
Lines 327-333 sub ModItemFromMarc { Link Here
327
    $item_object = $item_object->set_or_blank($item);
327
    $item_object = $item_object->set_or_blank($item);
328
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
328
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
329
    $item_object->more_subfields_xml(_get_unlinked_subfields_xml($unlinked_item_subfields));
329
    $item_object->more_subfields_xml(_get_unlinked_subfields_xml($unlinked_item_subfields));
330
    $item_object->store({ skip_modzebra_update => $params->{skip_modzebra_update} });
330
    $item_object->store({ skip_record_index => $params->{skip_record_index} });
331
331
332
    return $item_object->unblessed;
332
    return $item_object->unblessed;
333
}
333
}
(-)a/Koha/Item.pm (-4 / +4 lines)
Lines 61-67 Koha::Item - Koha Item object class Link Here
61
61
62
    $item->store;
62
    $item->store;
63
63
64
$params can take an optional 'skip_modzebra_update' parameter.
64
$params can take an optional 'skip_record_index' parameter.
65
If set, the reindexation process will not happen (index_records not called)
65
If set, the reindexation process will not happen (index_records not called)
66
66
67
NOTE: This is a temporary fix to answer a performance issue when lot of items
67
NOTE: This is a temporary fix to answer a performance issue when lot of items
Lines 113-119 sub store { Link Here
113
113
114
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
114
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
115
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
115
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
116
            unless $params->{skip_modzebra_update};
116
            unless $params->{skip_record_index};
117
117
118
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
118
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
119
          if $log_action && C4::Context->preference("CataloguingLog");
119
          if $log_action && C4::Context->preference("CataloguingLog");
Lines 190-196 sub store { Link Here
190
190
191
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
191
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
192
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
192
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
193
            unless $params->{skip_modzebra_update};
193
            unless $params->{skip_record_index};
194
194
195
        $self->_after_item_action_hooks({ action => 'modify' });
195
        $self->_after_item_action_hooks({ action => 'modify' });
196
196
Lines 218-224 sub delete { Link Here
218
218
219
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
219
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
220
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
220
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
221
        unless $params->{skip_modzebra_update};
221
        unless $params->{skip_record_index};
222
222
223
    $self->_after_item_action_hooks({ action => 'delete' });
223
    $self->_after_item_action_hooks({ action => 'delete' });
224
224
(-)a/cataloguing/additem.pl (-2 / +2 lines)
Lines 615-621 if ($op eq "additem") { Link Here
615
		# Adding the item
615
		# Adding the item
616
        if (!$exist_itemnumber) {
616
        if (!$exist_itemnumber) {
617
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
617
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
618
                AddItemFromMarc( $record, $biblionumber, { skip_modzebra_update => 1 } );
618
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
619
            set_item_default_location($oldbibitemnum);
619
            set_item_default_location($oldbibitemnum);
620
620
621
            # We count the item only if it was really added
621
            # We count the item only if it was really added
Lines 705-711 if ($op eq "additem") { Link Here
705
#-------------------------------------------------------------------------------
705
#-------------------------------------------------------------------------------
706
    my $items = Koha::Items->search({ biblionumber => $biblionumber });
706
    my $items = Koha::Items->search({ biblionumber => $biblionumber });
707
    while ( my $item = $items->next ) {
707
    while ( my $item = $items->next ) {
708
        $error = $item->safe_delete({ skip_modzebra_update => 1 });
708
        $error = $item->safe_delete({ skip_record_index => 1 });
709
        next if ref $error eq 'Koha::Item'; # Deleted item is returned if deletion successful
709
        next if ref $error eq 'Koha::Item'; # Deleted item is returned if deletion successful
710
        push @errors,$error;
710
        push @errors,$error;
711
    }
711
    }
(-)a/t/db_dependent/Koha/SearchEngine/Indexer.t (-6 / +6 lines)
Lines 99-106 subtest 'Test indexer calls' => sub { Link Here
99
            $item2 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
99
            $item2 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
100
        } [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)";
100
        } [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)";
101
        warnings_are{
101
        warnings_are{
102
            $item->store({ skip_modzebra_update => 1 });
102
            $item->store({ skip_record_index => 1 });
103
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_modzebra_update passed";
103
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed";
104
104
105
        $builder->build({
105
        $builder->build({
106
            source => 'Branchtransfer',
106
            source => 'Branchtransfer',
Lines 118-132 subtest 'Test indexer calls' => sub { Link Here
118
                datearrived => undef}
118
                datearrived => undef}
119
        });
119
        });
120
        warnings_are{
120
        warnings_are{
121
            LostItem( $item->itemnumber, "tests", undef, { skip_modzebra_update => 1 });
121
            LostItem( $item->itemnumber, "tests", undef, { skip_record_index => 1 });
122
        } undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_modzebra_update";
122
        } undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_record_index";
123
123
124
        warnings_are{
124
        warnings_are{
125
            $item->delete();
125
            $item->delete();
126
        } [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)";
126
        } [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)";
127
        warnings_are{
127
        warnings_are{
128
            $item2->delete({ skip_modzebra_update => 1 });
128
            $item2->delete({ skip_record_index => 1 });
129
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_modzebra_update passed";
129
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed";
130
130
131
        warnings_are{
131
        warnings_are{
132
            DelBiblio( $biblio->biblionumber );
132
            DelBiblio( $biblio->biblionumber );
(-)a/tools/batchMod.pl (-3 / +2 lines)
Lines 302-308 if ($op eq "action") { Link Here
302
                                                $localmarcitem,
302
                                                $localmarcitem,
303
                                                $itemdata->{biblionumber},
303
                                                $itemdata->{biblionumber},
304
                                                $itemnumber,
304
                                                $itemnumber,
305
                                                { skip_modzebra_update => 1 },
305
                                                { skip_record_index => 1 },
306
                                            )
306
                                            )
307
                                          )
307
                                          )
308
                                        {
308
                                        {
Lines 310-316 if ($op eq "action") { Link Here
310
                                                $itemnumber,
310
                                                $itemnumber,
311
                                                'batchmod',
311
                                                'batchmod',
312
                                                undef,
312
                                                undef,
313
                                                { skip_modzebra_update => 1 }
313
                                                { skip_record_index => 1 }
314
                                            ) if $item->{itemlost}
314
                                            ) if $item->{itemlost}
315
                                              and not $itemdata->{itemlost};
315
                                              and not $itemdata->{itemlost};
316
                                        }
316
                                        }
317
- 

Return to bug 25265