summaryrefslogtreecommitdiff
path: root/FS/FS/cust_svc.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-02-19 13:44:54 -0800
committerMark Wells <mark@freeside.biz>2016-02-24 11:33:51 -0800
commitfc951f6ed5fab5c3b36f79f9f413556f76e75e0c (patch)
tree8abdfdee0e0b965647e1cfbe9e436645fea4eec1 /FS/FS/cust_svc.pm
parent6a8cfb9dfdc9a48b840623fdf878cd4001482a57 (diff)
clean up dangling cust_svc records, related to #32043
Diffstat (limited to 'FS/FS/cust_svc.pm')
-rw-r--r--FS/FS/cust_svc.pm20
1 files changed, 13 insertions, 7 deletions
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index 0223f93..13e2e0f 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -1300,13 +1300,19 @@ sub _upgrade_data {
my $svcdb = $cust_svc->part_svc->svcdb;
$h_search{'hashref'}{'svcnum'} = $svcnum;
$h_search{'table'} = "h_$svcdb";
- my $h_svc_x = qsearchs(\%h_search)
- or next;
- my $class = "FS::$svcdb";
- my $new_svc_x = $class->new({ $h_svc_x->hash });
- my $error = $new_svc_x->insert;
- warn "error repairing svcnum $svcnum ($svcdb) from history:\n$error\n"
- if $error;
+ my $h_svc_x = qsearchs(\%h_search);
+ if ( $h_svc_x ) {
+ my $class = "FS::$svcdb";
+ my $new_svc_x = $class->new({ $h_svc_x->hash });
+ my $error = $new_svc_x->insert;
+ warn "error repairing svcnum $svcnum ($svcdb) from history:\n$error\n"
+ if $error;
+ } else {
+ # can't be fixed, so remove the dangling cust_svc to avoid breaking
+ # stuff
+ my $error = $cust_svc->delete;
+ warn "error cleaning up missing svcnum $svcnum ($svcdb):\n$error\n";
+ }
}
'';