[Rt-commit] rtir branch, 2.6/stop-clobbering-session-collection, created. 2.6.2rc1-14-g33e5793

Kevin Falcone falcone at bestpractical.com
Wed Sep 26 14:53:20 EDT 2012


The branch, 2.6/stop-clobbering-session-collection has been created
        at  33e5793b1aef21bcdb7ca840706c0e82992d040b (commit)

- Log -----------------------------------------------------------------
commit 33f5cf65cce5347cca70ee4f787fbbc146775bc9
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Sep 25 18:05:53 2012 -0400

    Stop clobbering the collection of tickets stored in your session
    
    Without this, things like Incident/Reply.html will stick the search for
    IRs into your session, on top of a recent search you did. It also makes
    the last search on your homepage your current session search.
    
    However, we do need to update the session when showing search results,
    so we'll keep the option of clobbering $session{'tickets'} around and
    use it in Results.html.
    
    This really just needs to reuse RT search infrastructure.

diff --git a/html/RTIR/Search/Elements/ShowResults b/html/RTIR/Search/Elements/ShowResults
index f5ff7df..bf705bf 100644
--- a/html/RTIR/Search/Elements/ShowResults
+++ b/html/RTIR/Search/Elements/ShowResults
@@ -72,7 +72,7 @@ $Query = join ' AND ', map "( $_ )", grep $_, $BaseQuery, $Query;
 $BaseURL = RT->Config->Get('WebPath')."/$BaseURL" unless $BaseURL =~ m{^/};
 $BaseURL .= ( $BaseURL =~ /\?/ )? '&': '?' unless $BaseURL =~ m{[&?]$};
 
-my $collection = $session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} );
+my $collection = RT::Tickets->new( $session{'CurrentUser'} );
 $collection->FromSQL( $Query );
 my $result = $m->scomp( '/Elements/TicketList',
     %ARGS,
@@ -86,14 +86,17 @@ my $result = $m->scomp( '/Elements/TicketList',
     AllowSorting   => $AllowSorting,
 );
 
-$session{'CurrentSearchHash'} = {
-    Format      => $Format,
-    Query       => $Query,
-    Page        => $Page,
-    Order       => $Order,
-    OrderBy     => $OrderBy,
-    RowsPerPage => $Rows
-};
+if ( $UpdateSession ) {
+    $session{'tickets'} = $collection;
+    $session{'CurrentSearchHash'} = {
+        Format      => $Format,
+        Query       => $Query,
+        Page        => $Page,
+        Order       => $Order,
+        OrderBy     => $OrderBy,
+        RowsPerPage => $Rows
+    };
+}
 
 return '' if !$ShowEmpty && !$result;
 
@@ -115,4 +118,5 @@ $ShowEmpty       => 0
 $ShowNavigation  => 0
 $ShowListActions => $ShowNavigation
 $AllowSorting    => 1
+$UpdateSession   => 0
 </%ARGS>
diff --git a/html/RTIR/Search/Results.html b/html/RTIR/Search/Results.html
index 937d00b..c39140a 100644
--- a/html/RTIR/Search/Results.html
+++ b/html/RTIR/Search/Results.html
@@ -76,7 +76,8 @@
     Page           => $Page,
     OrderBy        => $OrderBy,
     Order          => $Order,
-    ShowNavigation => 1
+    ShowNavigation => 1,
+    UpdateSession  => 1
 &>
 <div align="right">
 

commit 1c87cf1d97d95a7e1f88617fd04309d6b7e9f62e
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Sep 25 18:55:54 2012 -0400

    Count in ShowResults.
    
    Since this happens after the listing, it should be fast (and Count
    rather than CountAll allows us to use the cached results since we're
    paging).  All we actually care about is "were tickets listed in the box"
    so there's no need to skip the paging.
    
    This is ugly, but better than converting all the code to use
    TicketList which is a larger solution for a later trunk.

diff --git a/html/RTIR/Incident/Reply.html b/html/RTIR/Incident/Reply.html
index 5f38d13..215944d 100644
--- a/html/RTIR/Incident/Reply.html
+++ b/html/RTIR/Incident/Reply.html
@@ -48,6 +48,7 @@
 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
 
 % my $recipients = 0;
+% my $count = 0;
 
 <h2><&|/l&>Reporters</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
@@ -61,8 +62,9 @@
     Page          => $Page,
     OrderBy       => $OrderBy,
     Order         => $Order,
+    Count         => \$count,
 &>
-% $recipients += $session{'tickets'}->CountAll;
+% $recipients += $count;
 % if ( $All ) {
 <h2><&|/l&>Investigation Correspondents</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
@@ -76,8 +78,9 @@
     Page          => $Page,
     OrderBy       => $OrderBy,
     Order         => $Order,
+    Count         => \$count,
 &>
-% $recipients += $session{'tickets'}->CountAll;
+% $recipients += $count;
 % unless( RT->Config->Get('RTIR_DisableBlocksQueue') ) {
 <h2><&|/l&>Blocks Correspondents</&></h2>
 <& /RTIR/Search/Elements/ShowResults,
@@ -91,8 +94,9 @@
     Page          => $Page,
     OrderBy       => $OrderBy,
     Order         => $Order,
+    Count         => \$count,
 &>
-% $recipients += $session{'tickets'}->CountAll;
+% $recipients += $count;
 % }
 % }
 
diff --git a/html/RTIR/Search/Elements/ShowResults b/html/RTIR/Search/Elements/ShowResults
index bf705bf..ebc0f03 100644
--- a/html/RTIR/Search/Elements/ShowResults
+++ b/html/RTIR/Search/Elements/ShowResults
@@ -98,6 +98,10 @@ if ( $UpdateSession ) {
     };
 }
 
+if (ref $Count) {
+    $$Count = $collection->Count;
+}
+
 return '' if !$ShowEmpty && !$result;
 
 </%INIT>
@@ -119,4 +123,5 @@ $ShowNavigation  => 0
 $ShowListActions => $ShowNavigation
 $AllowSorting    => 1
 $UpdateSession   => 0
+$Count           => undef
 </%ARGS>

commit 520e65da0f5c63630e41d76a76dea918f7121b00
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Sep 26 10:28:58 2012 -0400

    Nothing ever thaws the limits, so stop freezing.
    
    This is incredibly old copied code.

diff --git a/html/RTIR/Elements/PickRestriction b/html/RTIR/Elements/PickRestriction
index e91b0cf..33ee2f5 100644
--- a/html/RTIR/Elements/PickRestriction
+++ b/html/RTIR/Elements/PickRestriction
@@ -23,7 +23,6 @@
 %# 
 %# END LICENSE BLOCK
 <form method="get">
-<input type="hidden" name="Bookmark" value="<% $session{'tickets'}->FreezeLimits()|u %>" />
 <input type="hidden" name="Queue" value="<%$ARGS{'Queue'}%>" />
 <&| /Widgets/TitleBox, title => loc('Refine search')&>
 <input type="hidden" name="id" value="<%$ARGS{'id'}%>" />

commit 4351def94fd7156bfae4f0ccda3a59b138527cff
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Sep 26 10:29:54 2012 -0400

    More counting code
    
    Again, this is better done if we start building collections and calling
    TicketList, but since I'm aiming for the 'small' fix, convert to using the
    Count argument and use that to tell if anything was rendered.
    
    Also, since the collection is no longer in %session, we don't have to
    force a re-search.  The rebuilding of the collection will force the
    search.

diff --git a/html/RTIR/Incident/BulkAbandon.html b/html/RTIR/Incident/BulkAbandon.html
index 71edf36..440af53 100644
--- a/html/RTIR/Incident/BulkAbandon.html
+++ b/html/RTIR/Incident/BulkAbandon.html
@@ -38,6 +38,7 @@
 
 <%PERL>
 # XXX: cache result set to check if get empty results
+my $count = 0;
 my $result_set = $m->scomp('/RTIR/Search/Elements/ShowResults',
     Queue         => $Queue,
     BaseURL       => $BaseURL,
@@ -50,11 +51,12 @@ my $result_set = $m->scomp('/RTIR/Search/Elements/ShowResults',
     Order         => $Order,
     Page          => $Page,
     ShowNavigation  => 1,
-    ShowListActions => 0
+    ShowListActions => 0,
+    Count         => \$count
 );
 </%PERL>
 
-% if( $session{'tickets'}->Count ) {
+% if( $count ) {
 % $m->out( $result_set );
 
 <&| /Widgets/TitleBox, title => loc("Select recipients") &>
@@ -156,8 +158,6 @@ if ( $ARGS{'BulkAbandon'} ) {
          map { ref($_)? loc( "Ticket [_1]: [_2]", $_->[0], $_->[1] ): $_ }
          @tempresults;
 
-    # force redo search if we changed tickets
-    $session{'tickets'}->RedoSearch if $session{'tickets'};
 }
 
 # We can only reject new tickets, so set the states.
diff --git a/html/RTIR/Report/BulkReject.html b/html/RTIR/Report/BulkReject.html
index 707a421..1d1889f 100644
--- a/html/RTIR/Report/BulkReject.html
+++ b/html/RTIR/Report/BulkReject.html
@@ -42,6 +42,7 @@
 <input type="hidden" name="OrderBy" value="<% $OrderBy %>" />
 <input type="hidden" name="Order"   value="<% $Order %>" />
 
+% my $count = 0;
 <& /RTIR/Search/Elements/ShowResults,
     Queue           => $Queue,
     BaseURL         => $BaseURL,
@@ -55,9 +56,10 @@
     Order           => $Order,
     ShowNavigation  => 1,
     ShowListActions => 0,
+    Count           => \$count,
 &>
 
-% if ( $session{'tickets'}->Count ) {
+% if ( $count ) {
 <& /Elements/Submit,
     Name => "BulkReject",
     Caption => loc("Reject selected incident reports"),
@@ -135,8 +137,6 @@ if ( $BulkReject ) {
     }
     push @results, map { ref($_)? loc( "Ticket [_1]: [_2]", $_->[0], $_->[1] ): $_ }
                    @tempresults;
-    # force redo search if we changed state
-    $session{'tickets'}->RedoSearch if $session{'tickets'};
 
     if ( $BulkRejectAndReturn ) {
         my $key = Digest::MD5::md5_hex( rand(1024) );

commit 33e5793b1aef21bcdb7ca840706c0e82992d040b
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Sep 26 10:31:22 2012 -0400

    Pass the collection down through these components
    
    From the first commit of Lookup.html, it used %session to avoid passing
    collections to other components.  I can't see any reason for that, other
    than clobbering the currently stored search (which you can still do by
    clicking on Refine Search).
    
    This rips out the session munging and just passes arguments down the
    component calls.  I expect there's some subtle action at a distance
    being missed, but this looks straightforward.

diff --git a/html/RTIR/Elements/ChildSummary b/html/RTIR/Elements/ChildSummary
index ac06fa9..cac9b1a 100644
--- a/html/RTIR/Elements/ChildSummary
+++ b/html/RTIR/Elements/ChildSummary
@@ -38,7 +38,7 @@
 % }
 
 % my $i=0;
-% while (my $Ticket = $session{'tickets'}->Next) {
+% while ( my $Ticket = $tickets->Next ) {
 % next unless ($Ticket->QueueObj->Name eq $Queue);
 % $i++;
 % my $t = RT::IR::TicketType( Ticket => $Ticket );
@@ -114,6 +114,7 @@ my $QueryString = $m->comp('/Elements/QueryString',
 $Queue => undef
 $Type => undef
 $ticket => undef
+$tickets => undef
 $q => undef
 $lookuptype => undef
 $Format => undef 
diff --git a/html/RTIR/Elements/IncidentSummary b/html/RTIR/Elements/IncidentSummary
index 2136345..3908f40 100644
--- a/html/RTIR/Elements/IncidentSummary
+++ b/html/RTIR/Elements/IncidentSummary
@@ -74,11 +74,8 @@
 </table>
 
 <%INIT>
-$session{'tickets'} ||= RT::Tickets->new( $session{'CurrentUser'} );
-$session{'tickets'}->GotoFirstItem;
-
 my $incidents;
-while ( my $Ticket = $session{'tickets'}->Next ) {
+while ( my $Ticket = $tickets->Next ) {
     if ( $Ticket->QueueObj->Name eq "Incidents" ) {
         $incidents->{ $Ticket->Id } = { Ticket => $Ticket };
     } elsif ( $Ticket->QueueObj->Name eq "Incident Reports" ) {
@@ -124,6 +121,7 @@ $Type => undef
 $ticket => undef
 $lookuptype => undef
 $q => undef
+$tickets => undef
 
 $Format => undef 
 $Rows => 50
diff --git a/html/RTIR/Tools/Elements/LookupRelatedTickets b/html/RTIR/Tools/Elements/LookupRelatedTickets
index 4f86592..4c63ee5 100644
--- a/html/RTIR/Tools/Elements/LookupRelatedTickets
+++ b/html/RTIR/Tools/Elements/LookupRelatedTickets
@@ -7,6 +7,7 @@
     ticket     => $TicketObj->id, 
     lookuptype => $LookupType, 
     q          => $q,
+    tickets    => $tickets,
 &>
 </&>
 
@@ -19,6 +20,7 @@
     ticket     => $TicketObj->id, 
     lookuptype => $LookupType, 
     q          => $q,
+    tickets    => $tickets,
 &>
 </&>
 
@@ -31,6 +33,7 @@
     ticket     => $TicketObj->id,
     lookuptype => $LookupType,
     q          => $q,
+    tickets    => $tickets,
 &>
 </&>
 
@@ -44,6 +47,7 @@
     ticket     => $TicketObj->id,
     lookuptype => $LookupType,
     q          => $q,
+    tickets    => $tickets,
 &>
 </&>
 </td></tr>
@@ -54,6 +58,7 @@
 $TicketObj
 $LookupType => undef
 $q => undef
+$tickets => undef
 </%args>
 <%init>
 my $TicketType = RT::IR::TicketType( Ticket => $TicketObj );
diff --git a/html/RTIR/Tools/Lookup.html b/html/RTIR/Tools/Lookup.html
index 2913ffb..0ef6185 100644
--- a/html/RTIR/Tools/Lookup.html
+++ b/html/RTIR/Tools/Lookup.html
@@ -37,7 +37,7 @@
 % }
 
 % if ( ! $HideResults ) {
-<& Elements/LookupRelatedTickets, TicketObj => $TicketObj, LookupType => $type, q => $q &>
+<& Elements/LookupRelatedTickets, TicketObj => $TicketObj, LookupType => $type, q => $q, tickets => $tickets &>
 % }
 
 <hr>
@@ -81,7 +81,7 @@ my $now = RT::Date->new( $session{'CurrentUser'} );
 $now->SetToNow;
 $now->AddDays( $max_age );
 
-$session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} );
+my $tickets = RT::Tickets->new( $session{'CurrentUser'} );
 
 my $current_subtab = 'RTIR/Tools/Lookup.html';
 if ( $q ) {
@@ -99,7 +99,7 @@ if ( $q ) {
         $query = "( $query ) AND TransactionDate > '". $now->ISO ."'"
     }
 
-    my ($val, $msg) = $session{'tickets'}->FromSQL( $query );
+    my ($val, $msg) = $tickets->FromSQL( $query );
     $RT::Logger->warning( $msg ) unless $val;
 }
 

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


More information about the Rt-commit mailing list