[Rt-commit] rt branch, 4.4/fix-deserialize-recently-viewed-tickets, created. rt-4.4.3-61-g16a71b6b8

Craig Kaiser craig at bestpractical.com
Wed Oct 31 09:50:57 EDT 2018


The branch, 4.4/fix-deserialize-recently-viewed-tickets has been created
        at  16a71b6b82c1bb79122b6aa5ea5dea5b78c19cdc (commit)

- Log -----------------------------------------------------------------
commit 16a71b6b82c1bb79122b6aa5ea5dea5b78c19cdc
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon Oct 29 16:24:06 2018 -0400

    Load Content rather than Attribute object for RecentlyViewedTickets
    
    Previously, if the RecentlyViewedTickets content somehow was set
    to undef, $content still evaluated to true because it was an
    RT::Attribute object. Calling the Content method then resulted in:
    
        Can't use an undefined value as an ARRAY reference
    
    This caused a 500 error for the end-user.
    
    Loading the content provides the intended true/false value and handles
    the empty content case.

diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index daae994e7..2b5cba65f 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2081,9 +2081,14 @@ Returns a list of two-element (ticket id, timestamp) array references ordered by
 =cut
 
 sub RecentlyViewedTickets {
-    my $self = shift;
-    my $content = $self->FirstAttribute('RecentlyViewedTickets');
-    return $content ? @{$content->Content} : ();
+    my $self    = shift;
+
+    my $attribute = $self->FirstAttribute('RecentlyViewedTickets');
+    my $content;
+
+    $content = $attribute->Content if $attribute;
+
+    return $content ? @{$content} : ();
 }
 
 =head2 AddRecentlyViewedTicket TICKET
@@ -2102,7 +2107,11 @@ sub AddRecentlyViewedTicket {
     return unless $ticket->Id;
 
     my @recentTickets;
-    my $content = $self->FirstAttribute('RecentlyViewedTickets');
+    my $attribute = $self->FirstAttribute('RecentlyViewedTickets');
+    my $content;
+
+    $content = $attribute->Content if $attribute;
+
     $content = $content ? $content->Content : [];
     if (defined $content) {
         @recentTickets = @$content;

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


More information about the rt-commit mailing list