fix deletion of objects with options, fallout from #13971
authorMark Wells <mark@freeside.biz>
Tue, 25 Feb 2014 03:11:34 +0000 (19:11 -0800)
committerMark Wells <mark@freeside.biz>
Tue, 25 Feb 2014 03:11:34 +0000 (19:11 -0800)
FS/FS/option_Common.pm
FS/FS/part_export.pm
bin/test_scrub_sql

index c1dda22..74adbed 100644 (file)
@@ -134,13 +134,7 @@ sub delete {
   my $oldAutoCommit = $FS::UID::AutoCommit;
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
-
-  my $error = $self->SUPER::delete;
-  if ( $error ) {
-    $dbh->rollback if $oldAutoCommit;
-    return $error;
-  }
-  
   my $pkey = $self->primary_key;
   #my $option_table = $self->option_table;
 
@@ -152,6 +146,12 @@ sub delete {
     }
   }
 
+  my $error = $self->SUPER::delete;
+  if ( $error ) {
+    $dbh->rollback if $oldAutoCommit;
+    return $error;
+  }
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
 
   '';
index 8e10ea7..9d261f0 100644 (file)
@@ -161,6 +161,10 @@ sub delete {
     'link_table'    => 'export_nas',
     'target_table'  => 'nas',
     'params'        => [],
+  ) || $self->process_m2m(
+    'link_table'    => 'export_svc',
+    'target_table'  => 'part_svc',
+    'params'        => [],
   ) || $self->SUPER::delete;
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
index fb26fe9..fe66805 100755 (executable)
 
 foreach my $table (qw(
   part_export_option
-  payment_gateway
   payment_gateway_option
+  payment_gateway
   agent_payment_gateway
-  queue
   queue_arg
+  queue
   cust_pay_batch
 )) {
   print "DELETE FROM $table;\n";