[freeside-commits] freeside/FS/FS Record.pm,1.210,1.211

Ivan,,, ivan at wavetail.420.am
Wed Aug 25 02:25:58 PDT 2010


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

Modified Files:
	Record.pm 
Log Message:
roll back the import transaction on fatal parsing errors on CDR import, so the cdr_batch record gets removed and db doesn't throw a dup key error, RT#9135

Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -w -d -r1.210 -r1.211
--- Record.pm	13 Aug 2010 05:55:33 -0000	1.210
+++ Record.pm	25 Aug 2010 09:25:56 -0000	1.211
@@ -1871,7 +1871,13 @@
     while ( scalar(@later) ) {
       my $sub = shift @later;
       my $data = shift @later;
-      &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf);
+      eval {
+        &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf)
+      };
+      if ( $@ ) {
+        $dbh->rollback if $oldAutoCommit;
+        return "can't insert record". ( $line ? " for $line" : '' ). ": $@";
+      }
       last if exists( $param->{skiprow} );
     }
     next if exists( $param->{skiprow} );
@@ -1902,9 +1908,12 @@
 
   }
 
-  $dbh->commit or die $dbh->errstr if $oldAutoCommit;;
+  unless ( $imported || $param->{empty_ok} ) {
+    $dbh->rollback if $oldAutoCommit;
+    return "Empty file!";
+  }
 
-  return "Empty file!" unless $imported || $param->{empty_ok};
+  $dbh->commit or die $dbh->errstr if $oldAutoCommit;;
 
   ''; #no error
 



More information about the freeside-commits mailing list