[Rt-commit] rtir branch, fix-misuse-of-tickets-in-session, created. 2.6.0-30-g896e8f5

Ruslan Zakirov ruz at bestpractical.com
Wed Jul 27 18:49:19 EDT 2011


The branch, fix-misuse-of-tickets-in-session has been created
        at  896e8f5959db1012a5f0eb7223f1b61ee2efd920 (commit)

- Log -----------------------------------------------------------------
commit 896e8f5959db1012a5f0eb7223f1b61ee2efd920
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Jul 28 02:42:37 2011 +0400

    always update tickets in the session
    
    re-using collection may result in wrong order and other artefacts
    
    Also, let TicketList deal with everything

diff --git a/html/RTIR/Search/Elements/ShowResults b/html/RTIR/Search/Elements/ShowResults
index 4703241..f7d783a 100644
--- a/html/RTIR/Search/Elements/ShowResults
+++ b/html/RTIR/Search/Elements/ShowResults
@@ -1,14 +1,4 @@
-<& /Elements/TicketList,
-    %ARGS,
-    Collection => $collection,
-    OrderBy => $OrderBy,
-    Order => $Order,
-    Rows => $Rows,
-    Page => $Page,
-    BaseURL => $BaseURL,
-    ShowNavigation => $ShowNavigation,
-    AllowSorting => $AllowSorting,
-&>
+<% $result |n %>
 
 % if ( $ShowListActions ) {
 <div align="right">
@@ -79,23 +69,33 @@ if ( $session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => $RT::Sys
 
 $Query = join ' AND ', map "( $_ )", grep $_, $BaseQuery, $Query;
 
-my $collection = $session{'tickets'} || RT::Tickets->new( $session{'CurrentUser'} );
-$collection->FromSQL( $Query ) if $Query;
-$session{'tickets'} = $collection;
+$BaseURL = RT->Config->Get('WebPath')."/$BaseURL" unless $BaseURL =~ m{^/};
+$BaseURL .= ( $BaseURL =~ /\?/ )? '&': '?' unless $BaseURL =~ m{[&?]$};
 
-$OrderBy = join "|", @{$OrderBy} if ref $OrderBy;
-$Order   = join "|", @{$Order}   if ref $Order;
-if ( ( $OrderBy || '' ) ne ( $session{'CurrentSearchHash'}->{'OrderBy'} || '' )
-     || ( $Order || '') ne ( $session{'CurrentSearchHash'}->{'Order'}   || '' ) )
-{
-    $session{'CurrentSearchHash'}->{'OrderBy'} = $OrderBy;
-    $session{'CurrentSearchHash'}->{'Order'}   = $Order;
-}
+my $collection = $session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} );
+$collection->FromSQL( $Query );
+my $result = $m->scomp( '/Elements/TicketList',
+    %ARGS,
+    Collection     => $collection,
+    OrderBy        => $OrderBy,
+    Order          => $Order,
+    Rows           => $Rows,
+    Page           => $Page,
+    BaseURL        => $BaseURL,
+    ShowNavigation => $ShowNavigation,
+    AllowSorting   => $AllowSorting,
+);
 
-return '' if !$ShowEmpty && !$collection->CountAll;
+$session{'CurrentSearchHash'} = {
+    Format      => $Format,
+    Query       => $Query,
+    Page        => $Page,
+    Order       => $Order,
+    OrderBy     => $OrderBy,
+    RowsPerPage => $Rows
+};
 
-$BaseURL = RT->Config->Get('WebPath')."/$BaseURL" unless $BaseURL =~ m{^/};
-$BaseURL .= ( $BaseURL =~ /\?/ )? '&': '?' unless $BaseURL =~ m{[&?]$};
+return '' if !$ShowEmpty && !$result;
 
 </%INIT>
 <%ARGS>
@@ -106,8 +106,8 @@ $Query           => ''
 $Format          => ''
 $Rows            => undef
 $Page            => 1
-$OrderBy         => $session{'CurrentSearchHash'}->{'OrderBy'} || 'id'
-$Order           => $session{'CurrentSearchHash'}->{'Order'}   || 'ASC'
+$OrderBy         => 'id'
+$Order           => 'ASC'
 
 $BaseURL         => "RTIR/Search/Results.html?"
 

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


More information about the Rt-commit mailing list