bugfix: deletedbiblioitems row now added upon delete of a biblio
authorGalen Charlton <galen.charlton@liblime.com>
Wed, 31 Oct 2007 18:38:01 +0000 (13:38 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 1 Nov 2007 00:44:00 +0000 (19:44 -0500)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm

index 6c9fe4e..ab33ee4 100644 (file)
@@ -565,9 +565,6 @@ sub DelBiblio {
     #   and we would have no way to remove it (except manually in zebra, but I bet it would be very hard to handle the problem)
     ModZebra($biblionumber, "delete_record", "biblioserver", undef);
 
-    # delete biblio from Koha tables and save in deletedbiblio
-    $error = &_koha_delete_biblio( $dbh, $biblionumber );
-
     # delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems
     $sth =
       $dbh->prepare(
@@ -576,9 +573,16 @@ sub DelBiblio {
     while ( my $biblioitemnumber = $sth->fetchrow ) {
 
         # delete this biblioitem
-        $error = &_koha_delete_biblioitems( $dbh, $biblioitemnumber );
+        $error = _koha_delete_biblioitems( $dbh, $biblioitemnumber );
         return $error if $error;
     }
+
+    # delete biblio from Koha tables and save in deletedbiblio
+    # must do this *after* _koha_delete_biblioitems, otherwise
+    # delete cascade will prevent deletedbiblioitems rows
+    # from being generated by _koha_delete_biblioitems
+    $error = _koha_delete_biblio( $dbh, $biblionumber );
+
     &logaction(C4::Context->userenv->{'number'},"CATALOGUING","DELETE",$biblionumber,"") 
         if C4::Context->preference("CataloguingLog");
     return;