diff options
author | Mark Wells <mark@freeside.biz> | 2013-09-27 13:08:05 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-09-27 13:08:05 -0700 |
commit | 0792a884aea4a30b1c227875a88270928602ff00 (patch) | |
tree | 19ffd009929f7d17c9d5f1c46915d18ff934c53b /rt/lib | |
parent | c0cd3e464e443a2d42d7f519ba01685087c6b423 (diff) |
prevent nonexistent customer links from breaking ticket display, #25063
Diffstat (limited to 'rt/lib')
-rw-r--r-- | rt/lib/RT/URI/freeside/Internal.pm | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm index b0962860d..5dc92d421 100644 --- a/rt/lib/RT/URI/freeside/Internal.pm +++ b/rt/lib/RT/URI/freeside/Internal.pm @@ -152,6 +152,9 @@ sub AsStringLong { if ( $table eq 'cust_main' ) { my $rec = $self->_FreesideGetRecord(); + if (!$rec) { + return '<I>Customer #'.$self->{'fspkey'}.' (not found)</I>'; + } return '<A HREF="' . $self->HREF . '">' . small_custview( $rec->{'_object'}, scalar(FS::Conf->new->config('countrydefault')), @@ -192,21 +195,38 @@ sub CustomerResolver { } elsif ( $self->{fstable} eq 'cust_svc' ) { my $rec = $self->_FreesideGetRecord(); - return if !$rec; - my $cust_pkg = $rec->{'_object'}->cust_pkg; - if ( $cust_pkg ) { - my $URI = RT::URI->new($self->CurrentUser); - $URI->FromURI('freeside://freeside/cust_main/'.$cust_pkg->custnum); - return $URI->Resolver; + if ($rec) { + my $cust_pkg = $rec->{'_object'}->cust_pkg; + if ( $cust_pkg ) { + my $URI = RT::URI->new($self->CurrentUser); + $URI->FromURI('freeside://freeside/cust_main/'.$cust_pkg->custnum); + return $URI->Resolver; + } } + return; } return; } sub CustomerInfo { my $self = shift; - $self = $self->CustomerResolver or return; - my $rec = $self->_FreesideGetRecord() or return; + $self = $self->CustomerResolver; + my $rec; + my $rec = $self->_FreesideGetRecord() if $self; + if (!$rec) { + # AsStringLong will report an error; + # here, just avoid breaking things + my $error = { + AgentName => '', + CustomerClass => '', + CustomerTags => [], + Referral => '', + InvoiceEmail => '', + BillingType => '', + }; + return $error; + } + my $cust_main = delete $rec->{_object}; my $agent = $cust_main->agent; my $class = $cust_main->cust_class; |