X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=79e674d56a7d187d62e185da293c8b9849df85b9;hp=b02f7b7ed0dc3fa4d11754bd1ae97d11c19e1b16;hb=8d0e15c1c73639374443f5fd2c06334eb12bea44;hpb=38d7d779f1082e7373ab7c3e58e7944f379dd859 diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index b02f7b7ed..79e674d56 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2411,7 +2411,11 @@ reason and reason_otaker arguments will be taken from those objects. sub cancel_pkgs { my( $self, %opt ) = @_; - my $oldAutoCommit = $FS::UID::AutoCommit; + # we're going to cancel services, which is not reversible + # but on 3.x, don't strictly enforce this + warn "cancel_pkgs should not be run inside a transaction" + if $FS::UID::AutoCommit == 0; + local $FS::UID::AutoCommit = 0; return ( 'access denied' ) @@ -2427,7 +2431,7 @@ sub cancel_pkgs { my $ban = new FS::banned_pay $self->_new_banned_pay_hashref; my $error = $ban->insert; if ($error) { - dbh->rollback if $oldAutoCommit; + dbh->rollback; return ( $error ); } @@ -2445,13 +2449,16 @@ sub cancel_pkgs { 'time' => $cancel_time ); if ($error) { warn "Error billing during cancel, custnum ". $self->custnum. ": $error"; - dbh->rollback if $oldAutoCommit; + dbh->rollback; return ( "Error billing during cancellation: $error" ); } } + dbh->commit; + $FS::UID::AutoCommit = 1; my @errors; - # now cancel all services, the same way we would for individual packages + # now cancel all services, the same way we would for individual packages. + # if any of them fail, cancel the rest anyway. my @cust_svc = map { $_->cust_svc } @pkgs; my @sorted_cust_svc = map { $_->[0] } @@ -2468,7 +2475,6 @@ sub cancel_pkgs { push @errors, $error if $error; } if (@errors) { - dbh->rollback if $oldAutoCommit; return @errors; } @@ -2491,12 +2497,7 @@ sub cancel_pkgs { push @errors, 'pkgnum '.$_->pkgnum.': '.$error if $error; } - if (@errors) { - dbh->rollback if $oldAutoCommit; - return @errors; - } - - return; + return @errors; } sub _banned_pay_hashref {