Browse Source

Bug 27819: Spurious item deletion errors from delete_records_via_leader.pl

The job reports errors when deleting items.

The issue seems to be that Koha::Object->delete claims in the POD to
return -1, 0, or 1 as a result, but it in fact returns the Object
itself on a successful deletion

The errors are reported as:
ERROR DELETING ITEM 501740: Koha::Item=HASH(0x55ce407a1a78)

To recreate:
 1 - Find or create a record with some items
 2 - Ensure those  items can be deleted (not on loan, etc.)
 3 - Edit the record leader and set position 5 to 'd'
 4 - perl misc/cronjobs/delete_records_via_leader.pl -i -v --confirm
 5 - Deletion succeeds, but reports failure on items
 6 - Apply patch
 7 - Find or create a new record as above, but this time add an
     additional item and check it out to a patron
 8 - perl misc/cronjobs/delete_records_via_leader.pl -i -v
 9 - Test mode should report 1 item to be deleted, one with error
10 - perl misc/cronjobs/delete_records_via_leader.pl -i -v --confirm
11 - One item should be deleted, one item not, record not deleted
12 - check the item in
13 - perl misc/cronjobs/delete_records_via_leader.pl -i -v --confirm
14 - Successful deletion with no error reported

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Nick Clemens 5 months ago
committed by Jonathan Druart
parent
commit
02a404ef42
  1. 26
      misc/cronjobs/delete_records_via_leader.pl

26
misc/cronjobs/delete_records_via_leader.pl

@ -99,20 +99,24 @@ foreach my $m (@metadatas) {
foreach my $item ( @items ) {
my $itemnumber = $item->itemnumber;
my $error = $test ? "Test mode enabled" : $item->safe_delete;
$error = undef if $error eq '1';
if ($error) {
say "ERROR DELETING ITEM $itemnumber: $error";
}
else {
say "DELETED ITEM $itemnumber" if $verbose;
$deleted_items_count++;
if( $test ){
my $result = $item->safe_to_delete;
if ( $result eq "1") {
say "TEST MODE: Item $itemnumber would have been deleted";
} else {
say "TEST MODE: ERROR DELETING ITEM $itemnumber: $result";
}
} else {
my $result = $item->safe_delete;
if ( ref $result eq "Koha::Item" ){
say "DELETED ITEM $itemnumber" if $verbose;
$deleted_items_count++;
} else {
say "ERROR DELETING ITEM $itemnumber: $result";
}
}
$total_items_count++;
}
}
my $error = $test ? q{Test mode enabled} : DelBiblio($biblionumber);

Loading…
Cancel
Save