[freeside-commits] branch FREESIDE_4_BRANCH updated. c12e66e585bf0a8d7f5fc019cff7c3eb61fe574f

Jonathan Prykop jonathan at 420.am
Wed Oct 28 21:57:03 PDT 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  c12e66e585bf0a8d7f5fc019cff7c3eb61fe574f (commit)
      from  31c2a903d66c3a3856ff0075a899fa74f6667eb3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c12e66e585bf0a8d7f5fc019cff7c3eb61fe574f
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Oct 27 01:15:29 2015 -0500

    RT#38765: Foreign key error during selfservice signup

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 390c940..c7f849f 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -956,6 +956,8 @@ sub _realtime_bop_result {
          return $e;
        }
 
+       $cust_pay_pending->set('jobnum','');
+
     }
     
     if ( $options{'paynum_ref'} ) {
@@ -1064,8 +1066,9 @@ sub _realtime_bop_result {
        if ( $placeholder ) {
          my $error = $placeholder->depended_delete;
          $error ||= $placeholder->delete;
+         $cust_pay_pending->set('jobnum','');
          warn "error removing provisioning jobs after declined paypendingnum ".
-           $cust_pay_pending->paypendingnum. ": $error\n";
+           $cust_pay_pending->paypendingnum. ": $error\n" if $error;
        } else {
          my $e = "error finding job $jobnum for declined paypendingnum ".
               $cust_pay_pending->paypendingnum. "\n";
diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm
index 63274b1..1a54203 100644
--- a/FS/FS/cust_pay_pending.pm
+++ b/FS/FS/cust_pay_pending.pm
@@ -393,6 +393,8 @@ sub approve {
       warn $e;
       return $e;
     }
+    
+    $self->set('jobnum','');
   }
 
   if ( $opt{'paynum_ref'} ) {
diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm
index 67d124d..a0654a1 100644
--- a/FS/FS/queue.pm
+++ b/FS/FS/queue.pm
@@ -206,9 +206,27 @@ sub delete {
     }
   }
 
+  my $oldAutoCommit = $FS::UID::AutoCommit;
+  local $FS::UID::AutoCommit = 0;
+  my $dbh = dbh;
+
+  foreach my $cust_pay_pending (qsearch('cust_pay_pending',{ jobnum => $self->jobnum })) {
+    $cust_pay_pending->set('jobnum','');
+    my $error = $cust_pay_pending->replace();
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error;
+    }
+  }
+
   my $error = $self->SUPER::delete;
-  return $error if $error;
+  if ( $error ) {
+    $dbh->rollback if $oldAutoCommit;
+    return $error;
+  }
   
+  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
   unlink $reportname if $reportname;
 
   '';

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_main/Billing_Realtime.pm |    5 ++++-
 FS/FS/cust_pay_pending.pm           |    2 ++
 FS/FS/queue.pm                      |   20 +++++++++++++++++++-
 3 files changed, 25 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list