From c468e3f7d47e0bd17629609453444f0d76f93119 Mon Sep 17 00:00:00 2001 From: Liz Rea Date: Fri, 3 Jan 2020 21:18:27 +0000 Subject: [PATCH] Bug 24324: Resolve error with delete_records_via_leader.pl To test: Have a record with the 000 position 5 set to "deleted" (record status) Use koha-shell to run the job with the -i flag: perl misc/cronjobs/delete_records_via_leader.pl -c -i -v * items and the record should be deleted Mark another record with the 000 position 5 set to deleted (record status) Use koha-shell to run the job without the -i flag: perl misc/cronjobs/delete_records_via_leader.pl -c -v * if the record had items, it will not be deleted * if the record did not have items, it will be deleted. Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit b713241845e8f730b46c756fa65c4ddd17ed746b) Signed-off-by: Hayley Mapley --- misc/cronjobs/delete_records_via_leader.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/delete_records_via_leader.pl b/misc/cronjobs/delete_records_via_leader.pl index add109345e..50e68275ea 100755 --- a/misc/cronjobs/delete_records_via_leader.pl +++ b/misc/cronjobs/delete_records_via_leader.pl @@ -38,6 +38,7 @@ use C4::Items; use Koha::Database; use Koha::Biblios; use Koha::Biblio::Metadatas; +use Koha::Items; my $delete_items; my $confirm; @@ -85,7 +86,6 @@ my $total_records_count = @metadatas; 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'); @@ -94,9 +94,9 @@ foreach my $m (@metadatas) { if ($delete_items) { my $deleted_count = 0; my $biblio = Koha::Biblios->find( $biblionumber ); - my @items = $biblio ? $biblio->items : (); + my @items = Koha::Items->search( { biblionumber => $biblionumber } ); foreach my $item ( @items ) { - my $itemnumber = $item->itemnumber(); + my $itemnumber = $item->itemnumber; my $error = $test ? "Test mode enabled" : DelItemCheck( $biblionumber, $itemnumber ); $error = undef if $error eq '1'; -- 2.39.5