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

(-)a/C4/AuthoritiesMarc.pm (-2 / +8 lines)
Lines 663-674 Deletes $authid and calls merge to cleanup linked biblio records. Link Here
663
Parameter skip_merge is used in authorities/merge.pl. You should normally not
663
Parameter skip_merge is used in authorities/merge.pl. You should normally not
664
use it.
664
use it.
665
665
666
skip_record_index will skip the indexation step.
667
666
=cut
668
=cut
667
669
668
sub DelAuthority {
670
sub DelAuthority {
669
    my ( $params ) = @_;
671
    my ( $params ) = @_;
670
    my $authid = $params->{authid} || return;
672
    my $authid = $params->{authid} || return;
671
    my $skip_merge = $params->{skip_merge};
673
    my $skip_merge = $params->{skip_merge};
674
    my $skip_record_index = $params->{skip_record_index} || 0;
675
672
    my $dbh = C4::Context->dbh;
676
    my $dbh = C4::Context->dbh;
673
677
674
    # Remove older pending merge requests for $authid to itself. (See bug 22437)
678
    # Remove older pending merge requests for $authid to itself. (See bug 22437)
Lines 678-685 sub DelAuthority { Link Here
678
    merge({ mergefrom => $authid }) if !$skip_merge;
682
    merge({ mergefrom => $authid }) if !$skip_merge;
679
    $dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid );
683
    $dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid );
680
    logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
684
    logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
681
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
685
    unless ( $skip_record_index ) {
682
    $indexer->index_records( $authid, "recordDelete", "authorityserver", undef );
686
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
687
        $indexer->index_records( $authid, "recordDelete", "authorityserver", undef );
688
    }
683
689
684
    _after_authority_action_hooks({ action => 'delete', authority_id => $authid });
690
    _after_authority_action_hooks({ action => 'delete', authority_id => $authid });
685
}
691
}
(-)a/Koha/BackgroundJob/BatchDeleteAuthority.pm (-3 / +17 lines)
Lines 3-11 package Koha::BackgroundJob::BatchDeleteAuthority; Link Here
3
use Modern::Perl;
3
use Modern::Perl;
4
use JSON qw( encode_json decode_json );
4
use JSON qw( encode_json decode_json );
5
5
6
use Koha::DateUtils qw( dt_from_string );
7
use C4::AuthoritiesMarc;
6
use C4::AuthoritiesMarc;
8
7
8
use Koha::DateUtils qw( dt_from_string );
9
use Koha::SearchEngine;
10
use Koha::SearchEngine::Indexer;
11
9
use base 'Koha::BackgroundJob';
12
use base 'Koha::BackgroundJob';
10
13
11
sub job_type {
14
sub job_type {
Lines 46-52 sub process { Link Here
46
        $schema->storage->txn_begin;
49
        $schema->storage->txn_begin;
47
50
48
        my $authid = $record_id;
51
        my $authid = $record_id;
49
        eval { C4::AuthoritiesMarc::DelAuthority({ authid => $authid }) };
52
        eval {
53
            C4::AuthoritiesMarc::DelAuthority(
54
                { authid => $authid, skip_record_index => 1 } );
55
        };
50
        if ( $@ ) {
56
        if ( $@ ) {
51
            push @messages, {
57
            push @messages, {
52
                type => 'error',
58
                type => 'error',
Lines 69-74 sub process { Link Here
69
        $self->progress( ++$job_progress )->store;
75
        $self->progress( ++$job_progress )->store;
70
    }
76
    }
71
77
78
    my @deleted_authids =
79
      map { $_->{code} eq 'authority_deleted' ? $_->{authid} : () }
80
          @messages;
81
82
    if ( @deleted_authids ) {
83
        my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX });
84
        $indexer->index_records( \@deleted_authids, "recordDelete", "authorityserver" );
85
    }
86
72
    my $job_data = decode_json $self->data;
87
    my $job_data = decode_json $self->data;
73
    $job_data->{messages} = \@messages;
88
    $job_data->{messages} = \@messages;
74
    $job_data->{report} = $report;
89
    $job_data->{report} = $report;
75
- 

Return to bug 30459