From: khoff Date: Fri, 1 Apr 2005 22:52:11 +0000 (+0000) Subject: Trap, and attempt to resolve, problems caused by missing history records. X-Git-Tag: BEFORE_FINAL_MASONIZE~607 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;ds=sidebyside;h=29c80b06fd677d43ff94d4503bb577107c71882e;p=freeside.git Trap, and attempt to resolve, problems caused by missing history records. --- diff --git a/FS/FS/h_cust_svc.pm b/FS/FS/h_cust_svc.pm index 17be97d62..0cbac4a18 100644 --- a/FS/FS/h_cust_svc.pm +++ b/FS/FS/h_cust_svc.pm @@ -40,9 +40,25 @@ Returns a list consisting of: sub label { my $self = shift; carp "FS::h_cust_svc::label called on $self" if $DEBUG; - my $svc_x = $self->h_svc_x(@_) - or die "can't find h_". $self->part_svc->svcdb. '.svcnum '. $self->svcnum; - $self->_svc_label($svc_x, @_); + my $svc_x = $self->h_svc_x(@_); + my $part_svc = $self->part_svc; + + unless ($svc_x) { + carp "can't find h_". $self->part_svc->svcdb. '.svcnum '. $self->svcnum if $DEBUG; + return $part_svc->svc, 'n/a', $part_svc->svcdb; + } + + my @label; + eval { @label = $self->_svc_label($svc_x, @_); }; + + if ($@) { + carp 'while resolving history record for svcdb/svcnum ' . + $part_svc->svcdb . '/' . $self->svcnum . ': ' . $@ if $DEBUG; + return $part_svc->svc, 'n/a', $part_svc->svcdb; + } else { + return @label; + } + } =item h_svc_x END_TIMESTAMP [ START_TIMESTAMP ] diff --git a/FS/FS/h_svc_acct.pm b/FS/FS/h_svc_acct.pm index 95c5c413a..247d20c9a 100644 --- a/FS/FS/h_svc_acct.pm +++ b/FS/FS/h_svc_acct.pm @@ -1,14 +1,18 @@ package FS::h_svc_acct; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $DEBUG ); +use Carp qw(carp); use FS::Record qw(qsearchs); use FS::h_Common; use FS::svc_acct; +use FS::svc_domain; use FS::h_svc_domain; @ISA = qw( FS::h_Common FS::svc_acct ); +$DEBUG = 0; + sub table { 'h_svc_acct' }; =head1 NAME @@ -33,6 +37,27 @@ sub svc_domain { ); } +=item domain + +Returns the domain associated with this account. + +=cut + +sub domain { + my $self = shift; + die "svc_acct.domsvc is null for svcnum ". $self->svcnum unless $self->domsvc; + + my $svc_domain = $self->svc_domain(@_) || $self->SUPER::svc_domain() + or die 'no history svc_domain.svcnum for svc_acct.domsvc ' . $self->domsvc; + + carp 'Using FS::svc_acct record in place of missing FS::h_svc_acct record.' + if ($svc_domain->isa('FS::svc_acct') and $DEBUG); + + $svc_domain->domain; + +} + + =back =head1 DESCRIPTION diff --git a/FS/FS/h_svc_www.pm b/FS/FS/h_svc_www.pm index 30ec366e4..7931061f9 100644 --- a/FS/FS/h_svc_www.pm +++ b/FS/FS/h_svc_www.pm @@ -1,7 +1,8 @@ package FS::h_svc_www; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $DEBUG ); +use Carp qw(carp); use FS::Record qw(qsearchs); use FS::h_Common; use FS::svc_www; @@ -9,6 +10,8 @@ use FS::h_domain_record; @ISA = qw( FS::h_Common FS::svc_www ); +$DEBUG = 0; + sub table { 'h_svc_www' }; =head1 NAME @@ -27,10 +30,21 @@ FS::h_svc_www - Historical web virtual host objects sub domain_record { my $self = shift; - qsearchs( 'h_domain_record', - { 'recnum' => $self->recnum }, - FS::h_domain_record->sql_h_searchs(@_), - ); + + carp 'Called FS::h_svc_www->domain_record on svcnum ' . $self->svcnum if $DEBUG; + + my $domain_record = qsearchs( + 'h_domain_record', + { 'recnum' => $self->recnum }, + FS::h_domain_record->sql_h_searchs(@_), + ) || $self->SUPER::domain_record + or die "no history domain_record.recnum for svc_www.recnum ". $self->domsvc; + + carp 'Using FS::svc_acct record in place of missing FS::h_svc_acct record.' + if ($domain_record->isa('FS::domain_record') and $DEBUG); + + return $domain_record; + } =back