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