X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fsvc_domain.pm;h=a70c1a340fa58fd9ac1ebdc1155fc01b1760e144;hb=0b9841bf3fea52f423242313afc2cc058d6e6a46;hp=5cfe690818a3e1a8150128dee2e7304477a7ef91;hpb=a875d5b4fd2d12937c7a53bed773490e2f3ba50f;p=freeside.git diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index 5cfe69081..a70c1a340 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -11,7 +11,7 @@ use Mail::Internet; use Mail::Header; use Date::Format; use Net::Whois 1.0; -use FS::Record qw(fields qsearch qsearchs); +use FS::Record qw(fields qsearch qsearchs dbh); use FS::Conf; use FS::svc_Common; use FS::cust_svc; @@ -152,6 +152,10 @@ sub insert { local $SIG{TSTP} = 'IGNORE'; local $SIG{PIPE} = 'IGNORE'; + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + $error = $self->check; return $error if $error; @@ -159,13 +163,20 @@ sub insert { if qsearchs( 'svc_domain', { 'domain' => $self->domain } ); my $whois = $self->whois; - return "Domain in use (see whois)" - if ( $self->action eq "N" && ! $whois_hack && $whois ); - return "Domain not found (see whois)" - if ( $self->action eq "M" && ! $whois ); + if ( $self->action eq "N" && ! $whois_hack && $whois ) { + $dbh->rollback if $oldAutoCommit; + return "Domain in use (see whois)"; + } + if ( $self->action eq "M" && ! $whois ) { + $dbh->rollback if $oldAutoCommit; + return "Domain not found (see whois)"; + } $error = $self->SUPER::insert; - return $error if $error; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } $self->submit_internic unless $whois_hack; @@ -179,7 +190,10 @@ sub insert { "$soarefresh $soaretry $soaexpire $soadefaultttl )" }; $error = $soa->insert; - warn "WARNING: couldn't insert SOA record for new domain: $error" if $error; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "couldn't insert SOA record for new domain: $error"; + } foreach my $nsmachine ( @nsmachines ) { my $ns = new FS::domain_record { @@ -190,8 +204,10 @@ sub insert { 'recdata' => $nsmachine, }; my $error = $ns->insert; - warn "WARNING: couldn't insert NS record for new domain: $error" - if $error; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "couldn't insert NS record for new domain: $error"; + } } foreach my $mxmachine ( @mxmachines ) { @@ -203,12 +219,15 @@ sub insert { 'recdata' => $mxmachine, }; my $error = $mx->insert; - warn "WARNING: couldn't insert MX record for new domain: $error" - if $error; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "couldn't insert MX record for new domain: $error"; + } } } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; #no error } @@ -459,7 +478,7 @@ sub submit_internic { =head1 VERSION -$Id: svc_domain.pm,v 1.7 2000-06-29 11:12:20 ivan Exp $ +$Id: svc_domain.pm,v 1.10 2001-04-22 01:56:15 ivan Exp $ =head1 BUGS @@ -476,7 +495,7 @@ The $recref stuff in sub check should be cleaned up. =head1 SEE ALSO L, L, L, L, -L, L, L, L, L, +L, L, L, L, L, schema.html from the base documentation, config.html from the base documentation.