[freeside-commits] branch FREESIDE_3_BRANCH updated. 58dfeb5412c54d676119d1c6b8a9ff7edde7e234
Christopher Burger
burgerc at freeside.biz
Wed Nov 21 10:19:15 PST 2018
The branch, FREESIDE_3_BRANCH has been updated
via 58dfeb5412c54d676119d1c6b8a9ff7edde7e234 (commit)
from b75b481f255cbe08d8e6e6768924a68af4e15f82 (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 58dfeb5412c54d676119d1c6b8a9ff7edde7e234
Author: Mark Wells <mark at freeside.biz>
Date: Wed Jul 20 09:43:38 2016 -0700
when canceling services across multiple packages, transaction-protect each one separately, from #37177
Conflicts:
FS/FS/cust_main.pm
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 88dd0e54b..d0d85b93a 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -34,6 +34,7 @@ use Date::Format;
use File::Temp; #qw( tempfile );
use Email::Address;
use Business::CreditCard 0.28;
+use Try::Tiny;
use FS::UID qw( getotaker dbh driver_name );
use FS::Record qw( qsearchs qsearch dbdef regexp_sql );
use FS::Misc qw( generate_email send_email generate_ps do_print money_pretty card_types );
@@ -2495,10 +2496,9 @@ sub cancel_pkgs {
}
dbh->commit;
- $FS::UID::AutoCommit = 1;
my @errors;
- # now cancel all services, the same way we would for individual packages.
- # if any of them fail, cancel the rest anyway.
+ # try to cancel each service, the same way we would for individual packages,
+ # but in cancel weight order.
my @cust_svc = map { $_->cust_svc } @pkgs;
my @sorted_cust_svc =
map { $_->[0] }
@@ -2511,8 +2511,15 @@ sub cancel_pkgs {
foreach my $cust_svc (@sorted_cust_svc) {
my $part_svc = $cust_svc->part_svc;
next if ( defined($part_svc) and $part_svc->preserve );
- my $error = $cust_svc->cancel; # immediate cancel, no date option
- push @errors, $error if $error;
+ # immediate cancel, no date option
+ # transactionize individually
+ my $error = try { $cust_svc->cancel } catch { $_ };
+ if ( $error ) {
+ dbh->rollback;
+ push @errors, $error;
+ } else {
+ dbh->commit;
+ }
}
if (@errors) {
return @errors;
@@ -2540,7 +2547,12 @@ sub cancel_pkgs {
}
}
my $error = $_->cancel(%lopt);
- push @errors, 'pkgnum '.$_->pkgnum.': '.$error if $error;
+ if ( $error ) {
+ dbh->rollback;
+ push @errors, 'pkgnum '.$_->pkgnum.': '.$error;
+ } else {
+ dbh->commit;
+ }
}
return @errors;
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main.pm | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
More information about the freeside-commits
mailing list