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

(-)a/C4/Biblio.pm (-4 / +10 lines)
Lines 351-357 Returns 1 on success 0 on failure Link Here
351
351
352
sub ModBiblio {
352
sub ModBiblio {
353
    my ( $record, $biblionumber, $frameworkcode, $options ) = @_;
353
    my ( $record, $biblionumber, $frameworkcode, $options ) = @_;
354
354
    $options //= {};
355
    $options //= {};
356
    my $skip_record_index = $options->{skip_record_index} || 0;
355
357
356
    if (!$record) {
358
    if (!$record) {
357
        carp 'No record passed to ModBiblio';
359
        carp 'No record passed to ModBiblio';
Lines 415-421 sub ModBiblio { Link Here
415
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
417
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
416
418
417
    # update the MARC record (that now contains biblio and items) with the new record data
419
    # update the MARC record (that now contains biblio and items) with the new record data
418
    ModBiblioMarc( $record, $biblionumber );
420
    ModBiblioMarc( $record, $biblionumber, { skip_record_index => $skip_record_index } );
419
421
420
    # modify the other koha tables
422
    # modify the other koha tables
421
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
423
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
Lines 2852-2863 Function exported, but should NOT be used, unless you really know what you're do Link Here
2852
sub ModBiblioMarc {
2854
sub ModBiblioMarc {
2853
    # pass the MARC::Record to this function, and it will create the records in
2855
    # pass the MARC::Record to this function, and it will create the records in
2854
    # the marcxml field
2856
    # the marcxml field
2855
    my ( $record, $biblionumber ) = @_;
2857
    my ( $record, $biblionumber, $params ) = @_;
2856
    if ( !$record ) {
2858
    if ( !$record ) {
2857
        carp 'ModBiblioMarc passed an undefined record';
2859
        carp 'ModBiblioMarc passed an undefined record';
2858
        return;
2860
        return;
2859
    }
2861
    }
2860
2862
2863
    my $skip_record_index = $params->{skip_record_index} || 0;
2864
2861
    # Clone record as it gets modified
2865
    # Clone record as it gets modified
2862
    $record = $record->clone();
2866
    $record = $record->clone();
2863
    my $dbh    = C4::Context->dbh;
2867
    my $dbh    = C4::Context->dbh;
Lines 2917-2924 sub ModBiblioMarc { Link Here
2917
    $m_rs->metadata( $record->as_xml_record($encoding) );
2921
    $m_rs->metadata( $record->as_xml_record($encoding) );
2918
    $m_rs->store;
2922
    $m_rs->store;
2919
2923
2920
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
2924
    unless ( $skip_record_index ) {
2921
    $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
2925
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
2926
        $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
2927
    }
2922
2928
2923
    return $biblionumber;
2929
    return $biblionumber;
2924
}
2930
}
(-)a/Koha/BackgroundJob/BatchUpdateBiblio.pm (-1 / +7 lines)
Lines 20-25 use JSON qw( decode_json encode_json ); Link Here
20
20
21
use Koha::DateUtils qw( dt_from_string );
21
use Koha::DateUtils qw( dt_from_string );
22
use Koha::Virtualshelves;
22
use Koha::Virtualshelves;
23
use Koha::SearchEngine;
24
use Koha::SearchEngine::Indexer;
23
25
24
use C4::Context;
26
use C4::Context;
25
use C4::Biblio;
27
use C4::Biblio;
Lines 89-95 sub process { Link Here
89
            C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record );
91
            C4::MarcModificationTemplates::ModifyRecordWithTemplate( $mmtid, $record );
90
            my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
92
            my $frameworkcode = C4::Biblio::GetFrameworkCode( $biblionumber );
91
            C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, {
93
            C4::Biblio::ModBiblio( $record, $biblionumber, $frameworkcode, {
92
                overlay_context => $args->{overlay_context},
94
                overlay_context   => $args->{overlay_context},
95
                skip_record_index => 1,
93
            });
96
            });
94
        };
97
        };
95
        if ( $error and $error != 1 or $@ ) { # ModBiblio returns 1 if everything as gone well
98
        if ( $error and $error != 1 or $@ ) { # ModBiblio returns 1 if everything as gone well
Lines 110-115 sub process { Link Here
110
        $self->progress( ++$job_progress )->store;
113
        $self->progress( ++$job_progress )->store;
111
    }
114
    }
112
115
116
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
117
    $indexer->index_records( \@record_ids, "specialUpdate", "biblioserver", undef, { index_now => 1 } );
118
113
    my $job_data = decode_json $self->data;
119
    my $job_data = decode_json $self->data;
114
    $job_data->{messages} = \@messages;
120
    $job_data->{messages} = \@messages;
115
    $job_data->{report} = $report;
121
    $job_data->{report} = $report;
(-)a/Koha/Items.pm (-5 / +6 lines)
Lines 353-363 sub batch_update { Link Here
353
            Koha::Items->search( { itemnumber => \@modified_itemnumbers } )
353
            Koha::Items->search( { itemnumber => \@modified_itemnumbers } )
354
                       ->get_column('biblionumber'));
354
                       ->get_column('biblionumber'));
355
355
356
        my $indexer = Koha::SearchEngine::Indexer->new(
356
        if ( @biblionumbers ) {
357
            { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
357
            my $indexer = Koha::SearchEngine::Indexer->new(
358
        $indexer->index_records( \@biblionumbers, 'specialUpdate',
358
                { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
359
            "biblioserver", undef )
359
360
          if @biblionumbers;
360
            $indexer->update_index( \@biblionumbers );
361
        }
361
    }
362
    }
362
363
363
    return ( { modified_itemnumbers => \@modified_itemnumbers, modified_fields => $modified_fields }, $self );
364
    return ( { modified_itemnumbers => \@modified_itemnumbers, modified_fields => $modified_fields }, $self );
(-)a/Koha/SearchEngine/Elasticsearch/Indexer.pm (-3 / +11 lines)
Lines 315-328 at the moment. Link Here
315
The other variables are used for parity with Zebra indexing calls. Currently the calls are passed through
315
The other variables are used for parity with Zebra indexing calls. Currently the calls are passed through
316
to Zebra as well.
316
to Zebra as well.
317
317
318
=item C<$more_params>
319
320
index_now can be set to force indexation on the fly.
321
322
=back
323
318
=cut
324
=cut
319
325
320
sub index_records {
326
sub index_records {
321
    my ( $self, $record_numbers, $op, $server, $records ) = @_;
327
    my ( $self, $record_numbers, $op, $server, $records, $more_params ) = @_;
322
    $record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers;
328
    $record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers;
323
    $records = [$records] if ref $records ne 'ARRAY' && defined $records;
329
    $records = [$records] if ref $records ne 'ARRAY' && defined $records;
330
331
    my $index_now = $more_params->{index_now} || 0;
332
324
    if ( $op eq 'specialUpdate' ) {
333
    if ( $op eq 'specialUpdate' ) {
325
        if ($records){
334
        if ( $records || $index_now ) {
326
            $self->update_index( $record_numbers, $records );
335
            $self->update_index( $record_numbers, $records );
327
        } else {
336
        } else {
328
            $self->update_index_background( $record_numbers, $server );
337
            $self->update_index_background( $record_numbers, $server );
329
- 

Return to bug 30465