Bug 22437: (follow-up) Move deletion of merge requests to DelAuthority
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 8 May 2020 06:46:59 +0000 (06:46 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 12 May 2020 10:02:05 +0000 (11:02 +0100)
Lines can be moved. Deletion can be done too if skip_merge is not set.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/AuthoritiesMarc.pm
authorities/merge.pl

index 9d059a0..c2aade8 100644 (file)
@@ -29,7 +29,7 @@ use C4::Charset;
 use C4::Log;
 use Koha::MetadataRecord::Authority;
 use Koha::Authorities;
-use Koha::Authority::MergeRequest;
+use Koha::Authority::MergeRequests;
 use Koha::Authority::Types;
 use Koha::Authority;
 use Koha::Libraries;
@@ -649,6 +649,11 @@ sub DelAuthority {
     my $authid = $params->{authid} || return;
     my $skip_merge = $params->{skip_merge};
     my $dbh = C4::Context->dbh;
+
+    # Remove older pending merge requests for $authid to itself. (See bug 22437)
+    my $condition = { authid => $authid, authid_new => [undef, 0, $authid], done => 0 };
+    Koha::Authority::MergeRequests->search($condition)->delete;
+
     merge({ mergefrom => $authid }) if !$skip_merge;
     $dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid );
     logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
index 5b8c4fb..37043bb 100755 (executable)
@@ -83,11 +83,7 @@ if ($merge) {
     my $MARCfrom = GetAuthority( $recordid2 );
     merge({ mergefrom => $recordid2, MARCfrom => $MARCfrom, mergeto => $recordid1, MARCto => $record });
 
-    # Delete the other record. Do not merge. It is unneeded and could under
-    # special circumstances have unwanted side-effects.
-    # Remove older pending merge requests for $recordid2 to itself. The above merge did the job already or will do. (See bug 22437)
-    my $condition = { authid => $recordid2, authid_new => [undef, 0, $recordid2], done => 0 };
-    Koha::Authority::MergeRequests->search($condition)->delete;
+    # Delete the other record. No need to merge.
     DelAuthority({ authid => $recordid2, skip_merge => 1 });
 
     # Parameters