[Rt-commit] rt branch, 4.0/reset-searchbuilder-flags, created. rt-4.0.8-326-g0a1be26

Todd Wade todd at bestpractical.com
Tue Jan 8 10:56:26 EST 2013


The branch, 4.0/reset-searchbuilder-flags has been created
        at  0a1be262c08ad204f474f74c5d2968843866b881 (commit)

- Log -----------------------------------------------------------------
commit 5e2aff457952a1d59c09f817c168d39425945e3e
Author: Todd Wade <todd at bestpractical.com>
Date:   Mon Jan 7 11:18:48 2013 -0500

    reset RT::SearchBuilder internal flags
    
    DBIx::SearchBuilder ::UnLimit and ::CleanSlate reset a search's query, but
    RT::SearchBulder has internal state that is recorded for searches also. This
    commit clears the internal flags so that a completely clean search can run.
    
    See [issues #20767]

diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 47c09a6..6d48f73 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -86,9 +86,23 @@ sub _Init  {
     $self->SUPER::_Init( 'Handle' => $RT::Handle);
 }
 
-sub CleanSlate {
+sub ResetInternalFlags {
     my $self = shift;
     $self->{'_sql_aliases'} = {};
+    delete $self->{'handled_disabled_column'};
+    delete $self->{'find_disabled_rows'};
+    $self->{'must_redo_search'} = 1;
+}
+
+sub UnLimit {
+    my $self = shift;
+    $self->ResetInternalFlags;
+    return $self->SUPER::UnLimit(@_);
+}
+
+sub CleanSlate {
+    my $self = shift;
+    $self->ResetInternalFlags;
     return $self->SUPER::CleanSlate(@_);
 }
 
diff --git a/t/api/searchbuilder.t b/t/api/searchbuilder.t
index 8562bfc..5660077 100644
--- a/t/api/searchbuilder.t
+++ b/t/api/searchbuilder.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test tests => 11;
+use RT::Test tests => 16;
 
 
 {
@@ -37,3 +37,19 @@ is_deeply(\@items_ids, \@sorted_ids, "ItemsArrayRef sorts alphabetically by name
 
 }
 
+#20767: UnLimit doesn't clear RT::SearchBuilder's flags for handling Disabled columns
+{
+  my $items;
+
+  ok(my $queues = RT::Queues->new(RT->SystemUser), 'Created a queues object');
+  ok( $queues->UnLimit(),'Unlimited the result set of the queues object');
+
+  $queues->FindAllRows;
+
+  $items = $queues->ItemsArrayRef();
+  is( @$items, 2, 'found disabled queue in search' );
+
+  ok( $queues->UnLimit(),'Unlimited the result set of the queues object');
+  $items = $queues->ItemsArrayRef();
+  is( @$items, 1, 'disabled queue was not in search' );
+}
\ No newline at end of file

commit 0a1be262c08ad204f474f74c5d2968843866b881
Author: Todd Wade <todd at bestpractical.com>
Date:   Mon Jan 7 11:46:17 2013 -0500

    linefeed at end of file

diff --git a/t/api/searchbuilder.t b/t/api/searchbuilder.t
index 5660077..6b964be 100644
--- a/t/api/searchbuilder.t
+++ b/t/api/searchbuilder.t
@@ -52,4 +52,5 @@ is_deeply(\@items_ids, \@sorted_ids, "ItemsArrayRef sorts alphabetically by name
   ok( $queues->UnLimit(),'Unlimited the result set of the queues object');
   $items = $queues->ItemsArrayRef();
   is( @$items, 1, 'disabled queue was not in search' );
-}
\ No newline at end of file
+}
+

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


More information about the Rt-commit mailing list