From e3e4764945d06b578ea16555c078389acc85ca22 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 18 Dec 2012 07:47:09 -0500 Subject: [PATCH] Bug 9231 - Batch revert staged MARC records fails if one or more records in a batch have been deleted. If a record in an imported batch is dleted, any attempt to revert the batch will result in the progress bar never reaching 100%. The background job dies when it hits the already deleted record, with the error occurring in C4::Items::DelItem for the line: $copy2deleted->execute( $record->as_usmarc(), $itemnumber ); which fails because $record is undefined. To keep the failure from causing the script to die, we just need to eval it. Then, even if it fails, the batch revert will keep going. Test Plan: 1) Stage a batch of marc records 2) Import those records 3) Delete one of those records 4) Attempt to revert the batch, it will hang. 5) Apply this patch 6) Repeat steps 1-4, the revert should succeed. --- C4/Items.pm | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index d9c31f9..bab538d 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -619,7 +619,7 @@ sub DelItem { # backup the record my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?"); - $copy2deleted->execute( $record->as_usmarc(), $itemnumber ); + eval { $copy2deleted->execute( $record->as_usmarc(), $itemnumber ); }; warn $@ if $@; # This last update statement makes that the timestamp column in deleteditems is updated too. If you remove these lines, please add a line to update the timestamp separately. See Bugzilla report 7146 and Biblio.pm (DelBiblio). #search item field code -- 1.7.2.5