From 1e4e276fe3c1355caca3e1a37fe706b397066664 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Wed, 4 Dec 2024 20:47:19 +0000 Subject: [PATCH] Bug 35654: (follow-up) Fix $holdings_count Fix the off by one error in the holdings_count to accurately print the number of remaining items. --- misc/cronjobs/delete_items.pl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/misc/cronjobs/delete_items.pl b/misc/cronjobs/delete_items.pl index 8e09271f54..75ffec6ee1 100755 --- a/misc/cronjobs/delete_items.pl +++ b/misc/cronjobs/delete_items.pl @@ -57,17 +57,15 @@ my $items = Koha::Items->search( \$where_clause ); DELITEM: while ( my $item = $items->next ){ - my $holdings_count = $item->biblio->items->count; - my $error; - my $safe_to_delete = $item->safe_to_delete; if ($safe_to_delete) { + my $holdings_count = $item->biblio->items->count - 1; $item->safe_delete if $commit; $verbose && say "$deleted_string item " . $item->itemnumber . " ($holdings_count items remain on record)"; - if ( $delete_biblios && $holdings_count == 1 ) { # aka DO-EET for empty bibs! - $error = &DelBiblio( $item->biblionumber ) if $commit; + if ( $delete_biblios && $holdings_count == 0 ) { # aka DO-EET for empty bibs! + my $error = &DelBiblio( $item->biblionumber ) if $commit; if ($error) { $verbose && say "Could not delete bib " . $item->biblionumber . ": $error"; } else { -- 2.39.5