[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for serious bug in LedgerSMB 1.2.16



Hi,

Sometimes, when re-posting an existing invoice, LedgerSMB
crashes with a primary-key constraint violation and
the invoice is lost!  This is very bad.

To replicate the problem:

1) Create an invoice and post it.

2) Go into the invoice and change something (for example, a description)
and repost.  Confirm that you want to post to an existing transaction.

3) If step (2) succeeded, try doing it again.  The second time, it should
blow up.

Here is a patch against LedgerSMB/IS.pm that fixes it.

Regards,

David.


--- IS.pm.ORIG  2009-02-12 10:52:17.000000000 -0500
+++ IS.pm       2009-02-12 10:50:32.000000000 -0500
@@ -1837,6 +1837,11 @@
   $sth->execute( $form->{id} ) || $form->dberror($query);
   $sth->finish;

+    $query = qq|DELETE FROM transactions WHERE id = ?|;
+    $sth = $dbh->prepare($query);
+    $sth->execute( $form->{id} ) || $form->dberror($query);
+    $sth->finish;
+
   # delete spool files
   $query = qq|
              SELECT spoolfile FROM status