Lines 21-26
package C4::AuthoritiesMarc;
Link Here
|
21 |
use strict; |
21 |
use strict; |
22 |
use warnings; |
22 |
use warnings; |
23 |
use MARC::Field; |
23 |
use MARC::Field; |
|
|
24 |
use Scalar::Util qw(blessed); |
25 |
use Try::Tiny qw( try catch ); |
24 |
|
26 |
|
25 |
use C4::Context; |
27 |
use C4::Context; |
26 |
use C4::Biblio qw( ModBiblio ); |
28 |
use C4::Biblio qw( ModBiblio ); |
Lines 34-39
use Koha::Authorities;
Link Here
|
34 |
use Koha::Authority::MergeRequests; |
36 |
use Koha::Authority::MergeRequests; |
35 |
use Koha::Authority::Types; |
37 |
use Koha::Authority::Types; |
36 |
use Koha::Authority; |
38 |
use Koha::Authority; |
|
|
39 |
use Koha::Database; |
37 |
use Koha::Libraries; |
40 |
use Koha::Libraries; |
38 |
use Koha::RecordProcessor; |
41 |
use Koha::RecordProcessor; |
39 |
use Koha::SearchEngine; |
42 |
use Koha::SearchEngine; |
Lines 718-738
sub DelAuthority {
Link Here
|
718 |
my $skip_merge = $params->{skip_merge}; |
721 |
my $skip_merge = $params->{skip_merge}; |
719 |
my $skip_record_index = $params->{skip_record_index} || 0; |
722 |
my $skip_record_index = $params->{skip_record_index} || 0; |
720 |
|
723 |
|
721 |
my $dbh = C4::Context->dbh; |
724 |
my $schema = Koha::Database->schema; |
722 |
|
725 |
try { |
723 |
# Remove older pending merge requests for $authid to itself. (See bug 22437) |
726 |
# TODO Make following lines part of transaction? Does merge take too long? |
724 |
my $condition = { authid => $authid, authid_new => [undef, 0, $authid], done => 0 }; |
727 |
# Remove older pending merge requests for $authid to itself. (See bug 22437) |
725 |
Koha::Authority::MergeRequests->search($condition)->delete; |
728 |
my $condition = { authid => $authid, authid_new => [ undef, 0, $authid ], done => 0 }; |
726 |
|
729 |
Koha::Authority::MergeRequests->search($condition)->delete; |
727 |
merge({ mergefrom => $authid }) if !$skip_merge; |
730 |
merge( { mergefrom => $authid } ) if !$skip_merge; |
728 |
$dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid ); |
731 |
|
729 |
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
732 |
my $authority = Koha::Authorities->find($authid); |
730 |
unless ( $skip_record_index ) { |
733 |
$schema->txn_do( |
731 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
734 |
sub { |
732 |
$indexer->index_records( $authid, "recordDelete", "authorityserver", undef ); |
735 |
$authority->move_to_deleted; #FIXME We should define 'move' .. |
733 |
} |
736 |
$authority->delete; |
|
|
737 |
} |
738 |
); |
734 |
|
739 |
|
735 |
_after_authority_action_hooks({ action => 'delete', authority_id => $authid }); |
740 |
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
|
|
741 |
unless ($skip_record_index) { |
742 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); |
743 |
$indexer->index_records( $authid, "recordDelete", "authorityserver", undef ); |
744 |
} |
745 |
_after_authority_action_hooks( { action => 'delete', authority_id => $authid } ); |
746 |
} catch { |
747 |
if ( blessed $_ && $_->can('rethrow') ) { |
748 |
$_->rethrow(); |
749 |
} else { |
750 |
die "Deleting authority $authid failed: " . $_; |
751 |
} |
752 |
}; |
736 |
} |
753 |
} |
737 |
|
754 |
|
738 |
=head2 ModAuthority |
755 |
=head2 ModAuthority |