[Rt-commit] rt branch, 4.2/reset-searchbuilder-flags, created. rt-4.0.8-325-ga8ce77e

Todd Wade todd at bestpractical.com
Fri Apr 12 12:51:58 EDT 2013


The branch, 4.2/reset-searchbuilder-flags has been created
        at  a8ce77ef3349c74729bd79b42df654dfb911e9eb (commit)

- Log -----------------------------------------------------------------
commit a8ce77ef3349c74729bd79b42df654dfb911e9eb
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..3f54988 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -86,9 +86,16 @@ 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'};
+}
+
+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..8456871 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 => 19;
 
 
 {
@@ -37,3 +37,27 @@ is_deeply(\@items_ids, \@sorted_ids, "ItemsArrayRef sorts alphabetically by name
 
 }
 
+#20767: CleanSlate 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');
+
+  # sanity check
+  is( $queues->{'handled_disabled_column'} => undef, 'handled_disabled_column IS NOT set' );
+  is( $queues->{'find_disabled_rows'}      => undef, 'find_disabled_rows IS NOT set ' );
+
+  $queues->LimitToDeleted;
+
+  # sanity check
+  ok( $queues->{'handled_disabled_column'}, 'handled_disabled_column IS set' );
+  ok( $queues->{'find_disabled_rows'},      'find_disabled_rows IS set ' );
+
+  $queues->CleanSlate;
+
+  # these fail without the overloaded CleanSlate method
+  is( $queues->{'handled_disabled_column'} => undef, 'handled_disabled_column IS NOT set' );
+  is( $queues->{'find_disabled_rows'}      => undef, 'find_disabled_rows IS NOT set ' );
+}
+

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


More information about the Rt-commit mailing list