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 734-754
sub DelAuthority {
Link Here
|
734 |
my $skip_merge = $params->{skip_merge}; |
737 |
my $skip_merge = $params->{skip_merge}; |
735 |
my $skip_record_index = $params->{skip_record_index} || 0; |
738 |
my $skip_record_index = $params->{skip_record_index} || 0; |
736 |
|
739 |
|
737 |
my $dbh = C4::Context->dbh; |
740 |
my $schema = Koha::Database->schema; |
738 |
|
741 |
try { |
739 |
# Remove older pending merge requests for $authid to itself. (See bug 22437) |
742 |
# TODO Make following lines part of transaction? Does merge take too long? |
740 |
my $condition = { authid => $authid, authid_new => [undef, 0, $authid], done => 0 }; |
743 |
# Remove older pending merge requests for $authid to itself. (See bug 22437) |
741 |
Koha::Authority::MergeRequests->search($condition)->delete; |
744 |
my $condition = { authid => $authid, authid_new => [ undef, 0, $authid ], done => 0 }; |
742 |
|
745 |
Koha::Authority::MergeRequests->search($condition)->delete; |
743 |
merge({ mergefrom => $authid }) if !$skip_merge; |
746 |
merge( { mergefrom => $authid } ) if !$skip_merge; |
744 |
$dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid ); |
747 |
|
745 |
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
748 |
my $authority = Koha::Authorities->find($authid); |
746 |
unless ( $skip_record_index ) { |
749 |
$schema->txn_do( |
747 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
750 |
sub { |
748 |
$indexer->index_records( $authid, "recordDelete", "authorityserver", undef ); |
751 |
$authority->move_to_deleted; #FIXME We should define 'move' .. |
749 |
} |
752 |
$authority->delete; |
|
|
753 |
} |
754 |
); |
750 |
|
755 |
|
751 |
_after_authority_action_hooks({ action => 'delete', authority_id => $authid }); |
756 |
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); |
|
|
757 |
unless ($skip_record_index) { |
758 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); |
759 |
$indexer->index_records( $authid, "recordDelete", "authorityserver", undef ); |
760 |
} |
761 |
_after_authority_action_hooks( { action => 'delete', authority_id => $authid } ); |
762 |
} catch { |
763 |
if ( blessed $_ && $_->can('rethrow') ) { |
764 |
$_->rethrow(); |
765 |
} else { |
766 |
die "Deleting authority $authid failed: " . $_; |
767 |
} |
768 |
}; |
752 |
} |
769 |
} |
753 |
|
770 |
|
754 |
=head2 ModAuthority |
771 |
=head2 ModAuthority |