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

(-)a/C4/AuthoritiesMarc.pm (-4 / +15 lines)
Lines 533-539 returns authid of the newly created authority Link Here
533
533
534
sub AddAuthority {
534
sub AddAuthority {
535
# pass the MARC::Record to this function, and it will create the records in the authority table
535
# pass the MARC::Record to this function, and it will create the records in the authority table
536
  my ($record,$authid,$authtypecode) = @_;
536
    my ( $record, $authid, $authtypecode, $params ) = @_;
537
538
    my $skip_record_index = $params->{skip_record_index} || 0;
539
537
  my $dbh=C4::Context->dbh;
540
  my $dbh=C4::Context->dbh;
538
	my $leader='     nz  a22     o  4500';#Leader for incomplete MARC21 record
541
	my $leader='     nz  a22     o  4500';#Leader for incomplete MARC21 record
539
542
Lines 642-649 sub AddAuthority { Link Here
642
    $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) );
645
    $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) );
643
    # Update
646
    # Update
644
    $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;
647
    $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;
645
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
648
646
    $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record );
649
    unless ( $skip_record_index ) {
650
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
651
        $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record );
652
    }
647
653
648
    _after_authority_action_hooks({ action => $action, authority_id => $authid });
654
    _after_authority_action_hooks({ action => $action, authority_id => $authid });
649
    return ( $authid );
655
    return ( $authid );
Lines 685-697 sub DelAuthority { Link Here
685
Modifies authority record, optionally updates attached biblios.
691
Modifies authority record, optionally updates attached biblios.
686
The parameter skip_merge is optional and should be used with care.
692
The parameter skip_merge is optional and should be used with care.
687
693
694
skip_record_index will skip the indexation step.
695
688
=cut
696
=cut
689
697
690
sub ModAuthority {
698
sub ModAuthority {
691
    my ( $authid, $record, $authtypecode, $params ) = @_;
699
    my ( $authid, $record, $authtypecode, $params ) = @_;
700
701
    my $skip_record_index = $params->{skip_record_index} || 0;
702
692
    my $oldrecord = GetAuthority($authid);
703
    my $oldrecord = GetAuthority($authid);
693
    #Now rewrite the $record to table with an add
704
    #Now rewrite the $record to table with an add
694
    $authid = AddAuthority($record, $authid, $authtypecode);
705
    $authid = AddAuthority($record, $authid, $authtypecode, { skip_record_index => $skip_record_index });
695
    merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge};
706
    merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge};
696
    logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog");
707
    logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog");
697
    return $authid;
708
    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", undef, { index_now => 1 } );
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