[freeside-commits] branch master updated. 0792a884aea4a30b1c227875a88270928602ff00

Mark Wells mark at 420.am
Fri Sep 27 13:12:33 PDT 2013


The branch, master has been updated
       via  0792a884aea4a30b1c227875a88270928602ff00 (commit)
      from  c0cd3e464e443a2d42d7f519ba01685087c6b423 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0792a884aea4a30b1c227875a88270928602ff00
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Sep 27 13:08:05 2013 -0700

    prevent nonexistent customer links from breaking ticket display, #25063

diff --git a/rt/lib/RT/URI/freeside/Internal.pm b/rt/lib/RT/URI/freeside/Internal.pm
index b096286..5dc92d4 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;
diff --git a/rt/share/html/Ticket/Elements/Customers b/rt/share/html/Ticket/Elements/Customers
index d90ef1c..fed6783 100644
--- a/rt/share/html/Ticket/Elements/Customers
+++ b/rt/share/html/Ticket/Elements/Customers
@@ -43,10 +43,12 @@ while (my $link = $customers->Next) {
   } elsif ( $uri =~ /cust_svc\/(\d+)/ ) {
     my $svc = $link->TargetURI->Resolver;
     my $cust = $svc->CustomerResolver;
-    my $custnum = $cust->{fspkey};
-    $cust_main{$custnum} ||= $cust;
-    $cust_svc{$custnum} ||= [];
-    push @{$cust_svc{$custnum}}, $svc;
+    if ( $cust ) {
+      my $custnum = $cust->{fspkey};
+      $cust_main{$custnum} ||= $cust if $cust;
+      $cust_svc{$custnum} ||= [];
+      push @{$cust_svc{$custnum}}, $svc if $svc;
+    }
   }
 }
 @custnums = sort { $a <=> $b } keys %cust_main;

-----------------------------------------------------------------------

Summary of changes:
 rt/lib/RT/URI/freeside/Internal.pm      |   36 ++++++++++++++++++++++++-------
 rt/share/html/Ticket/Elements/Customers |   10 +++++---
 2 files changed, 34 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list