Bugzilla – Attachment 19348 Details for
Bug 9231
Batch revert staged MARC records fails if one or more records in a batch have been deleted.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9231 - Batch revert staged MARC records fails if one or more records in a batch have been deleted.
Bug-9231---Batch-revert-staged-MARC-records-fails-.patch (text/plain), 3.03 KB, created by
Kyle M Hall
on 2013-07-02 15:18:56 UTC
(
hide
)
Description:
Bug 9231 - Batch revert staged MARC records fails if one or more records in a batch have been deleted.
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2013-07-02 15:18:56 UTC
Size:
3.03 KB
patch
obsolete
>From bf88d40d8ce956769249d656476fb59c3ba43704 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 2 Jul 2013 11:17:57 -0400 >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 | 27 +++++++++++++++++++-------- > 1 files changed, 19 insertions(+), 8 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 212a9d3..48abe4e 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -608,21 +608,32 @@ Exported function (core API) for deleting an item record in Koha. > > sub DelItem { > my ( $dbh, $biblionumber, $itemnumber ) = @_; >- >- # FIXME check the item has no current issues >+ >+ # FIXME: Why pass $dbh in? We can get it from C4::Context >+ # FIXME: Why pass $biblionumber in? It would be safer to get it via the itemnumber >+ >+ return unless ( DelItemCheck( $dbh, $biblionumber, $itemnumber ) eq '1' ); > > _koha_delete_item( $dbh, $itemnumber ); > > # get the MARC record > my $record = GetMarcBiblio($biblionumber); >- ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); > >- # backup the record >- my $copy2deleted = $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?"); >- $copy2deleted->execute( $record->as_usmarc(), $itemnumber ); >- # 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). >+ if ($record) { >+ >+ ModZebra( $biblionumber, "specialUpdate", "biblioserver" ); >+ >+ # backup the record >+ my $copy2deleted = >+ $dbh->prepare("UPDATE deleteditems SET marc=? WHERE itemnumber=?"); >+ $copy2deleted->execute( $record->as_usmarc(), $itemnumber ); >+ # 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). >+ } else { >+ warn "Can't backup delete item, record doesn't exist! Biblionumber: $biblionumber, Itemnumber: $itemnumber"; >+ } > >- #search item field code > logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog"); > } > >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9231
:
14186
|
17910
|
19348
|
19349
|
19350
|
20219