Bug 22437: Delete older merge requests at new merge time

If you merge A to B, we should remove older AA merges (regular
merge to itself) in the queue before deleting A.

Test plan:
[1] Set merge limit in prefs to say X.
[2] Find three authorities A, B, C with linkcount >X, >X, <X.
[3] Merge C to B. This creates a 'BB merge' in the queue.
    Auth C is deleted.
[4] Merge B to A. Creating AA and BA in the queue.
    Auth B is deleted.
    Optionally verify that BB is no longer in the queue.
[5] Run the merge_authorities.pl cron job.
    Verify that the linkcount to A is the former total of ABC.

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

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit 08aa52c831)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2020-04-03 08:55:45 +00:00 committed by Lucas Gass
parent b5807429f7
commit bcbabb7693
1 changed files with 4 additions and 0 deletions

View File

@ -25,6 +25,7 @@ use C4::AuthoritiesMarc;
use C4::Koha;
use C4::Biblio;
use Koha::Authority::MergeRequests;
use Koha::Authority::Types;
use Koha::MetadataRecord::Authority;
@ -84,6 +85,9 @@ if ($merge) {
# 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;
DelAuthority({ authid => $recordid2, skip_merge => 1 });
# Parameters