[Rt-commit] rt branch, 4.4/fix-deserialize-recently-viewed-tickets, created. rt-4.4.3-61-g33ae945f2
Craig Kaiser
craig at bestpractical.com
Mon Nov 5 09:56:45 EST 2018
The branch, 4.4/fix-deserialize-recently-viewed-tickets has been created
at 33ae945f2d86194f2e6549e435fe099970492eee (commit)
- Log -----------------------------------------------------------------
commit 33ae945f2d86194f2e6549e435fe099970492eee
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..6b4dffae4 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,8 +2107,12 @@ sub AddRecentlyViewedTicket {
return unless $ticket->Id;
my @recentTickets;
- my $content = $self->FirstAttribute('RecentlyViewedTickets');
- $content = $content ? $content->Content : [];
+ my $attribute = $self->FirstAttribute('RecentlyViewedTickets');
+ my $content;
+
+ $content = $attribute->Content if $attribute;
+
+ $content = $content ? $content : ();
if (defined $content) {
@recentTickets = @$content;
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list