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 115-121 sub store { Link Here
115
115
116
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
116
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
117
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
117
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
118
            unless $params->{skip_modzebra_update};
118
            unless $params->{skip_record_index};
119
119
120
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
120
        logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
121
          if $log_action && C4::Context->preference("CataloguingLog");
121
          if $log_action && C4::Context->preference("CataloguingLog");
Lines 192-198 sub store { Link Here
192
192
193
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
193
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
194
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
194
        $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
195
            unless $params->{skip_modzebra_update};
195
            unless $params->{skip_record_index};
196
196
197
        logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper($self->unblessed) )
197
        logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper($self->unblessed) )
198
          if $log_action && C4::Context->preference("CataloguingLog");
198
          if $log_action && C4::Context->preference("CataloguingLog");
Lines 221-227 sub delete { Link Here
221
221
222
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
222
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
223
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
223
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
224
        unless $params->{skip_modzebra_update};
224
        unless $params->{skip_record_index};
225
225
226
    $self->_after_item_action_hooks({ action => 'delete' });
226
    $self->_after_item_action_hooks({ action => 'delete' });
227
227
(-)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 113-120 subtest 'Test indexer calls' => sub { Link Here
113
            $item2 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
113
            $item2 = $builder->build_sample_item({biblionumber => $biblio->biblionumber});
114
        } [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)";
114
        } [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)";
115
        warnings_are{
115
        warnings_are{
116
            $item->store({ skip_modzebra_update => 1 });
116
            $item->store({ skip_record_index => 1 });
117
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_modzebra_update passed";
117
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed";
118
118
119
        $builder->build({
119
        $builder->build({
120
            source => 'Branchtransfer',
120
            source => 'Branchtransfer',
Lines 132-146 subtest 'Test indexer calls' => sub { Link Here
132
                datearrived => undef}
132
                datearrived => undef}
133
        });
133
        });
134
        warnings_are{
134
        warnings_are{
135
            LostItem( $item->itemnumber, "tests", undef, { skip_modzebra_update => 1 });
135
            LostItem( $item->itemnumber, "tests", undef, { skip_record_index => 1 });
136
        } undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_modzebra_update";
136
        } undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_record_index";
137
137
138
        warnings_are{
138
        warnings_are{
139
            $item->delete();
139
            $item->delete();
140
        } [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)";
140
        } [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)";
141
        warnings_are{
141
        warnings_are{
142
            $item2->delete({ skip_modzebra_update => 1 });
142
            $item2->delete({ skip_record_index => 1 });
143
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_modzebra_update passed";
143
        } undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed";
144
144
145
        warnings_are{
145
        warnings_are{
146
            DelBiblio( $biblio->biblionumber );
146
            DelBiblio( $biblio->biblionumber );
(-)a/tools/batchMod.pl (-3 / +2 lines)
Lines 304-310 if ($op eq "action") { Link Here
304
                                                $localmarcitem,
304
                                                $localmarcitem,
305
                                                $itemdata->{biblionumber},
305
                                                $itemdata->{biblionumber},
306
                                                $itemnumber,
306
                                                $itemnumber,
307
                                                { skip_modzebra_update => 1 },
307
                                                { skip_record_index => 1 },
308
                                            )
308
                                            )
309
                                          )
309
                                          )
310
                                        {
310
                                        {
Lines 312-318 if ($op eq "action") { Link Here
312
                                                $itemnumber,
312
                                                $itemnumber,
313
                                                'batchmod',
313
                                                'batchmod',
314
                                                undef,
314
                                                undef,
315
                                                { skip_modzebra_update => 1 }
315
                                                { skip_record_index => 1 }
316
                                            ) if $item->{itemlost}
316
                                            ) if $item->{itemlost}
317
                                              and not $itemdata->{itemlost};
317
                                              and not $itemdata->{itemlost};
318
                                        }
318
                                        }
319
- 

Return to bug 25265