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

(-)a/C4/AuthoritiesMarc.pm (-4 / +15 lines)
Lines 545-551 returns authid of the newly created authority Link Here
545
545
546
sub AddAuthority {
546
sub AddAuthority {
547
# pass the MARC::Record to this function, and it will create the records in the authority table
547
# pass the MARC::Record to this function, and it will create the records in the authority table
548
  my ($record,$authid,$authtypecode) = @_;
548
    my ( $record, $authid, $authtypecode, $params ) = @_;
549
550
    my $skip_record_index = $params->{skip_record_index} || 0;
551
549
  my $dbh=C4::Context->dbh;
552
  my $dbh=C4::Context->dbh;
550
	my $leader='     nz  a22     o  4500';#Leader for incomplete MARC21 record
553
	my $leader='     nz  a22     o  4500';#Leader for incomplete MARC21 record
551
554
Lines 654-661 sub AddAuthority { Link Here
654
    $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) );
657
    $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) );
655
    # Update
658
    # Update
656
    $dbh->do( "UPDATE auth_header SET authtypecode=?, marc=?, marcxml=? WHERE authid=?", undef, $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $authid ) or die $DBI::errstr;
659
    $dbh->do( "UPDATE auth_header SET authtypecode=?, marc=?, marcxml=? WHERE authid=?", undef, $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $authid ) or die $DBI::errstr;
657
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
660
658
    $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record );
661
    unless ( $skip_record_index ) {
662
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
663
        $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record );
664
    }
659
665
660
    _after_authority_action_hooks({ action => $action, authority_id => $authid });
666
    _after_authority_action_hooks({ action => $action, authority_id => $authid });
661
    return ( $authid );
667
    return ( $authid );
Lines 697-709 sub DelAuthority { Link Here
697
Modifies authority record, optionally updates attached biblios.
703
Modifies authority record, optionally updates attached biblios.
698
The parameter skip_merge is optional and should be used with care.
704
The parameter skip_merge is optional and should be used with care.
699
705
706
skip_record_index will skip the indexation step.
707
700
=cut
708
=cut
701
709
702
sub ModAuthority {
710
sub ModAuthority {
703
    my ( $authid, $record, $authtypecode, $params ) = @_;
711
    my ( $authid, $record, $authtypecode, $params ) = @_;
712
713
    my $skip_record_index = $params->{skip_record_index} || 0;
714
704
    my $oldrecord = GetAuthority($authid);
715
    my $oldrecord = GetAuthority($authid);
705
    #Now rewrite the $record to table with an add
716
    #Now rewrite the $record to table with an add
706
    $authid = AddAuthority($record, $authid, $authtypecode);
717
    $authid = AddAuthority($record, $authid, $authtypecode, { skip_record_index => $skip_record_index });
707
    merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge};
718
    merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge};
708
    logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog");
719
    logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog");
709
    return $authid;
720
    return $authid;
(-)a/Koha/BackgroundJob/BatchUpdateAuthority.pm (-2 / +6 lines)
Lines 23-28 use C4::AuthoritiesMarc qw( ModAuthority ); Link Here
23
use Koha::BackgroundJobs;
23
use Koha::BackgroundJobs;
24
use Koha::DateUtils qw( dt_from_string );
24
use Koha::DateUtils qw( dt_from_string );
25
use Koha::MetadataRecord::Authority;
25
use Koha::MetadataRecord::Authority;
26
use Koha::SearchEngine;
27
use Koha::SearchEngine::Indexer;
26
28
27
use base 'Koha::BackgroundJob';
29
use base 'Koha::BackgroundJob';
28
30
Lines 81-87 sub process { Link Here
81
            my $authority = Koha::MetadataRecord::Authority->get_from_authid( $authid );
83
            my $authority = Koha::MetadataRecord::Authority->get_from_authid( $authid );
82
            my $record = $authority->record;
84
            my $record = $authority->record;
83
            ModifyRecordWithTemplate( $mmtid, $record );
85
            ModifyRecordWithTemplate( $mmtid, $record );
84
            ModAuthority( $authid, $record, $authority->authtypecode );
86
            ModAuthority( $authid, $record, $authority->authtypecode, { skip_record_index => 1 } );
85
        };
87
        };
86
        if ( $error and $error != $authid or $@ ) {
88
        if ( $error and $error != $authid or $@ ) {
87
            push @messages, {
89
            push @messages, {
Lines 101-106 sub process { Link Here
101
        $self->progress( ++$job_progress )->store;
103
        $self->progress( ++$job_progress )->store;
102
    }
104
    }
103
105
106
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
107
    $indexer->index_records( \@record_ids, "specialUpdate", "authorityserver" );
108
104
    my $job_data = decode_json $self->data;
109
    my $job_data = decode_json $self->data;
105
    $job_data->{messages} = \@messages;
110
    $job_data->{messages} = \@messages;
106
    $job_data->{report} = $report;
111
    $job_data->{report} = $report;
107
- 

Return to bug 30464