From 32469eb7e0660e469b2ef38d5d1126dff701ae47 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Tue, 17 Jan 2023 12:18:00 -0500 Subject: [PATCH] Bug 32656: Script delete_records_via_leader.pl no longer deletes items Bug 29788 inadvertantly replaced a call to safe_delete() with safe_to_delete() such that any time the script should delete an item it only checks to see if the item is delectable, after which deletion of the record fails because the items were not deleted. Test Plan: 1) Mark a record with items to be deleted via the record leader 2) Run delete_records_via_leader.pl -i -b -v 3) Note the script says it is deleting the items but then the record deletion fails. Note the items remain in the items table of the database. 4) Apply this patch 5) Repeat step 2 6) This time the items and record should be deleted! Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize (cherry picked from commit 790f00781ab6c98017529ebf226d52c36c36cd68) Signed-off-by: Matt Blenkinsop (cherry picked from commit 03a9b139587aea26a9abde4f45a7c4f99532353c) Signed-off-by: Lucas Gass (cherry picked from commit 0f430ce9a8c3b98be260e48a3d66f5bbb40012ab) Signed-off-by: Arthur Suzuki --- misc/cronjobs/delete_records_via_leader.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/cronjobs/delete_records_via_leader.pl b/misc/cronjobs/delete_records_via_leader.pl index 8456f42c04..fc095ed60b 100755 --- a/misc/cronjobs/delete_records_via_leader.pl +++ b/misc/cronjobs/delete_records_via_leader.pl @@ -78,16 +78,16 @@ This script has the following parameters : exit(); } -my @metadatas = # Should be replaced by a call to C4::Search on zebra index +my $metadatas = # Should be replaced by a call to C4::Search on zebra index # Record-status when bug 15537 will be pushed Koha::Biblio::Metadatas->search( { format => 'marcxml', schema => C4::Context->preference('marcflavour'), metadata => { LIKE => '%_____d%' } } ); -my $total_records_count = @metadatas; +my $total_records_count = $metadatas->count; my $deleted_records_count = 0; my $total_items_count = 0; my $deleted_items_count = 0; -foreach my $m (@metadatas) { - my $biblionumber = $m->get_column('biblionumber'); +while ( my $m = $metadatas->next ) { + my $biblionumber = $m->biblionumber; say "RECORD: $biblionumber" if $verbose; -- 2.39.5