[freeside-commits] freeside/FS/FS cust_main.pm, 1.464.2.31, 1.464.2.32 cust_event.pm, 1.7.2.3, 1.7.2.4

Ivan,,, ivan at wavetail.420.am
Thu Jul 1 17:25:48 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv6774

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	cust_main.pm cust_event.pm 
Log Message:
fix bad transactional decisions that made it possible to abort and rollback a gateway payment, RT#8995

Index: cust_event.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_event.pm,v
retrieving revision 1.7.2.3
retrieving revision 1.7.2.4
diff -u -w -d -r1.7.2.3 -r1.7.2.4
--- cust_event.pm	30 Mar 2010 12:09:21 -0000	1.7.2.3
+++ cust_event.pm	2 Jul 2010 00:25:46 -0000	1.7.2.4
@@ -222,9 +222,6 @@
        " (". $part_event->action. ") $for\n"
     if $DEBUG;
 
-  my $oldAutoCommit = $FS::UID::AutoCommit;
-  local $FS::UID::AutoCommit = 0;
-
   my $error;
   {
     local $SIG{__DIE__}; # don't want Mason __DIE__ handler active

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.464.2.31
retrieving revision 1.464.2.32
diff -u -w -d -r1.464.2.31 -r1.464.2.32
--- cust_main.pm	11 Jun 2010 21:18:11 -0000	1.464.2.31
+++ cust_main.pm	2 Jul 2010 00:25:46 -0000	1.464.2.32
@@ -3492,19 +3492,17 @@
     }
   }
 
-  my $error = $self->do_cust_event(
+  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+  #never want to roll back an event just because it returned an error
+  local $FS::UID::AutoCommit = 1; #$oldAutoCommit;
+
+  $self->do_cust_event(
     'debug'      => ( $options{'debug'} || 0 ),
     'time'       => $invoice_time,
     'check_freq' => $options{'check_freq'},
     'stage'      => 'collect',
   );
-  if ( $error ) {
-    $dbh->rollback if $oldAutoCommit;
-    return $error;
-  }
-
-  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
-  '';
 
 }
 
@@ -3599,6 +3597,11 @@
     return $due_cust_event;
   }
 
+  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+  #never want to roll back an event just because it or a different one
+  # returned an error
+  local $FS::UID::AutoCommit = 1; #$oldAutoCommit;
+
   foreach my $cust_event ( @$due_cust_event ) {
 
     #XXX lock event
@@ -3607,11 +3610,7 @@
     unless ( $cust_event->test_conditions( 'time' => $time ) ) {
       #don't leave stray "new/locked" records around
       my $error = $cust_event->delete;
-      if ( $error ) {
-        #gah, even with transactions
-        $dbh->commit if $oldAutoCommit; #well.
-        return $error;
-      }
+      return $error if $error;
       next;
     }
 
@@ -3620,20 +3619,16 @@
       warn "  running cust_event ". $cust_event->eventnum. "\n"
         if $DEBUG > 1;
 
-      
       #if ( my $error = $cust_event->do_event(%options) ) { #XXX %options?
       if ( my $error = $cust_event->do_event() ) {
         #XXX wtf is this?  figure out a proper dealio with return value
         #from do_event
-	  # gah, even with transactions.
-	  $dbh->commit if $oldAutoCommit; #well.
 	  return $error;
 	}
     }
 
   }
 
-  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
   '';
 
 }



More information about the freeside-commits mailing list