X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fsvc_domain.pm;h=c533ee8705568fdfc3a4ece917b7da2cff1c3f51;hb=7d5a4fc43bd26705c3f4613b05bea6141864c9a9;hp=e1e4eb8b5a8f5350f3c1252cb376d7dcddef0bb2;hpb=051f66ab072bfbb2a074f656b9886ccbc47287ed;p=freeside.git diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index e1e4eb8b5..c533ee870 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 ); - 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 ) { @@ -199,16 +215,19 @@ sub insert { 'svcnum' => $self->svcnum, 'reczone' => '@', 'recaf' => 'IN', - 'rectype' => 'mx', + 'rectype' => 'MX', '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.6 2000-03-01 08:13:59 ivan Exp $ +$Id: svc_domain.pm,v 1.11 2001-05-22 16:43:28 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.