[Rt-commit] rt branch, 4.4/disable-recently-viewed-tickets, created. rt-4.4.4-45-ga62ac9352

? sunnavy sunnavy at bestpractical.com
Fri May 17 13:51:16 EDT 2019


The branch, 4.4/disable-recently-viewed-tickets has been created
        at  a62ac9352a95ca234d551840a53f5894d3b80765 (commit)

- Log -----------------------------------------------------------------
commit a62ac9352a95ca234d551840a53f5894d3b80765
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat May 18 01:33:44 2019 +0800

    Add config option $DisableRecentlyViewedTickets
    
    RT lists current user's recently viewed tickets in menu by default.
    Since it happens on most pages, it could slow down RT a bit.  With this
    config option, people can easily disable this feature.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 1ce94ba0f..0db75ecbc 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1213,6 +1213,15 @@ speed RT up a bit, at the expense of a tiny bit of data accuracy.
 
 Set($WebFlushDbCacheEveryRequest, 1);
 
+=item C<$DisableRecentlyViewedTickets>
+
+By default, current user's recently viewed tickets are listed in menu.
+Setting it to 1 to disable this feature, which could speed RT up a bit.
+
+=cut
+
+Set($DisableRecentlyViewedTickets, 0);
+
 =item C<%ChartFont>
 
 The L<GD> module (which RT uses for graphs) ships with a built-in font
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index c1dc4f490..4a878d2cb 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2247,6 +2247,8 @@ sub AddRecentlyViewedTicket {
     my $self   = shift;
     my $ticket = shift;
 
+    return ( 0, $self->loc('RecentlyViewedTickets is disabled') ) if RT->Config->Get('DisableRecentlyViewedTickets');
+
     my $maxCount = 10; #The max number of tickets to keep
 
     #Nothing to do without a ticket
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 755c8d219..576910cc3 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -603,20 +603,22 @@ my $build_main_nav = sub {
     $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
     $tickets->child( new    => title => loc('New Search'),    path => "/Search/Build.html?NewQuery=1" );
 
-    my $recents = $tickets->child( recent => title => loc('Recently Viewed'));
-    for ($session{CurrentUser}->RecentlyViewedTickets) {
-        my ($ticketId, $timestamp) = @$_;
-        my $ticket = RT::Ticket->new($session{CurrentUser});
-        $ticket->Load($ticketId);
-        if ($ticket->Id) {
-            my $title = $ticket->Subject || loc("(No subject)");
-            if (length $title > 50) {
-                $title = substr($title, 0, 47);
-                $title =~ s/\s+$//;
-                $title .= "...";
+    if ( !RT->Config->Get('DisableRecentlyViewedTickets') ) {
+        my $recents = $tickets->child( recent => title => loc('Recently Viewed'));
+        for ($session{CurrentUser}->RecentlyViewedTickets) {
+            my ($ticketId, $timestamp) = @$_;
+            my $ticket = RT::Ticket->new($session{CurrentUser});
+            $ticket->Load($ticketId);
+            if ($ticket->Id) {
+                my $title = $ticket->Subject || loc("(No subject)");
+                if (length $title > 50) {
+                    $title = substr($title, 0, 47);
+                    $title =~ s/\s+$//;
+                    $title .= "...";
+                }
+                $title = "#$ticketId: " . $title;
+                $recents->child( "$ticketId" => title => $title, path => "/Ticket/Display.html?id=" . $ticket->Id );
             }
-            $title = "#$ticketId: " . $title;
-            $recents->child( "$ticketId" => title => $title, path => "/Ticket/Display.html?id=" . $ticket->Id );
         }
     }
 

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


More information about the rt-commit mailing list