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

Craig Kaiser craig at bestpractical.com
Tue Oct 30 11:48:44 EDT 2018


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

- Log -----------------------------------------------------------------
commit 6e297c2d85207dbf819eaa662ae46ff52847bc75
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..e05f2d225 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

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


More information about the rt-commit mailing list