[Rt-commit] rt branch, 4.0/shredder-leftovers, created. rt-4.0.20-23-gb868ffa
Alex Vandiver
alexmv at bestpractical.com
Fri May 23 18:06:35 EDT 2014
The branch, 4.0/shredder-leftovers has been created
at b868ffa6aa20229691b755ddcb041966c6c8a4ae (commit)
- Log -----------------------------------------------------------------
commit b414bb1b83bf7b633544e95c688bd7f48a5e1fd5
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 17 16:10:04 2012 -0700
Shredder: Target the specific group when resolving Owner membership
Close over the group id instead of processing any Owner role group on
the dependency stack. Some Owner roles may want to be wiped.
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
index ed632e3..b3674ac 100644
--- a/lib/RT/Shredder/GroupMember.pm
+++ b/lib/RT/Shredder/GroupMember.pm
@@ -92,6 +92,8 @@ sub __DependsOn
return $self->SUPER::__DependsOn( %args );
}
+ my $target_group_id = $group->id;
+
# we don't delete group, so we have to fix Ticket and Group
$deps->_PushDependencies(
BaseObject => $self,
@@ -106,8 +108,7 @@ sub __DependsOn
my %args = (@_);
my $group = $args{'TargetObject'};
return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
- return unless ($group->Type || '') eq 'Owner';
- return unless ($group->Domain || '') eq 'RT::Ticket-Role';
+ return if $group->id != $target_group_id; # ensure we're resolving the right group
return if $group->MembersObj->Count > 1;
commit ca0ced24629215e5859894d75393e53f39898556
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 17 16:12:25 2012 -0700
Shredder: Wipeout the test objects as root to ensure SeeGroup doesn't interfere
Otherwise the ticket role groups may be left behind, causing test
failures.
diff --git a/t/shredder/03plugin_users.t b/t/shredder/03plugin_users.t
index 131ffa0..5009e62 100644
--- a/t/shredder/03plugin_users.t
+++ b/t/shredder/03plugin_users.t
@@ -91,7 +91,13 @@ create_savepoint('clean');
$transaction->Load($trid);
is ( $transaction->Creator, $uidA, "ticket creator is now user A" );
- $shredder->Wipeout( Object => $ticket );
- $shredder->Wipeout( Object => $userA );
+ $ticket = RT::Ticket->new( RT->SystemUser );
+ $ticket->Load($tid);
+
+ $shredder->PutObject( Object => $ticket );
+ $shredder->WipeoutAll;
+
+ $shredder->PutObject( Object => $userA );
+ $shredder->WipeoutAll;
}
cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");
commit 77a8bf9b91f0950e2b6d597fe7ed67c442a0aab8
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 17 15:45:01 2012 -0700
Shredder: Loop until all objects on the stack are WIPED
Visit every object pushed onto the stack and wipe it. This causes test
failures because resolvable dependencies (with flags DEPENDS_ON |
VARIABLE) are pushed onto the stack as well and should not be wiped.
The previous fix, 5bdf351, switched from "while each" to "for values" to
avoid the well-known side-effects of using each() when the hash is
modified inside the loop (pushing on new dependent objects). That
commit fixed "skipped object" problems caused by an unpredictable
each(), but didn't address the problem of objects pushed onto the stack
after "values" was evaluated.
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 125ed0d..d6fa3fd 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -554,9 +554,11 @@ sub WipeoutAll
{
my $self = $_[0];
- foreach my $cache_val ( values %{ $self->{'cache'} } ) {
- next if $cache_val->{'State'} & (WIPED | IN_WIPING);
- $self->Wipeout( Object => $cache_val->{'Object'} );
+ while (my @rec = grep { !($_->{State} & WIPED) } values %{ $self->{'cache'} }) {
+ for my $v (@rec) {
+ next if $v->{'State'} & IN_WIPING;
+ $self->Wipeout( Object => $v->{'Object'} );
+ }
}
}
commit b868ffa6aa20229691b755ddcb041966c6c8a4ae
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 17 16:00:29 2012 -0700
Shredder: Don't push resolvable dependencies onto the stack for wiping
If a dependency is marked VARIABLE (resolvable), require it is handled
by a resolver. The resolver is free to put the object on the stack
explicitly if resolution is not actually possible.
Such objects were often safe because of the accidental side-effects of
modifying the hash iterated by each() and later only calling values()
once. It is cleaner and safer to simply never push them onto the stack
in the first place. This lets you re-use shredder objects, for example,
without inadvertently wiping objects you didn't mean to on the second
call to WipeoutAll.
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index d6fa3fd..0a891c9 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -465,8 +465,8 @@ sub _ParseRefStrArgs
return '';
}
-sub GetObject { return (shift)->GetRecord( @_ )->{'Object'} }
-sub GetState { return (shift)->GetRecord( @_ )->{'State'} }
+sub GetObject { return ((shift)->GetRecord( @_ ) || {})->{'Object'} }
+sub GetState { return ((shift)->GetRecord( @_ ) || {})->{'State'} }
sub GetRecord
{
my $self = shift;
diff --git a/lib/RT/Shredder/Constants.pm b/lib/RT/Shredder/Constants.pm
index b71e191..9a70777 100644
--- a/lib/RT/Shredder/Constants.pm
+++ b/lib/RT/Shredder/Constants.pm
@@ -84,6 +84,11 @@ This flag is used to mark dependencies that can be resolved with changing
value in target object. For example ticket can be created by user we can
change this reference when we delete user.
+Dependencies with the VARIABLE flag are B<not> pushed onto the stack of objects
+to be wiped, only the list of dependencies. They must be handled by a resolver
+which either modifies the necessary values or pushes the object onto the stack
+with L<RT::Shredder/PutObject> if resolution is not possible.
+
=head2 RELATES
This flag is used to validate relationships integrity. Base object
diff --git a/lib/RT/Shredder/Dependencies.pm b/lib/RT/Shredder/Dependencies.pm
index fdfcb8b..35902e8 100644
--- a/lib/RT/Shredder/Dependencies.pm
+++ b/lib/RT/Shredder/Dependencies.pm
@@ -106,14 +106,15 @@ sub _PushDependency
Shredder => undef,
@_
);
- my $rec = $args{'Shredder'}->PutObject( Object => $args{'TargetObject'} );
- return if $rec->{'State'} & WIPED; # there is no object anymore
+ my $lookup = $args{Flags} & VARIABLE ? 'GetRecord' : 'PutObject';
+ my $rec = $args{'Shredder'}->$lookup( Object => $args{'TargetObject'} );
+ return if $rec and $rec->{'State'} & WIPED; # there is no object anymore
push @{ $self->{'list'} },
RT::Shredder::Dependency->new(
BaseObject => $args{'BaseObject'},
Flags => $args{'Flags'},
- TargetObject => $rec->{'Object'},
+ TargetObject => $args{'TargetObject'},
);
if( scalar @{ $self->{'list'} } > ( $RT::DependenciesLimit || 1000 ) ) {
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
index b3674ac..b988e6e 100644
--- a/lib/RT/Shredder/GroupMember.pm
+++ b/lib/RT/Shredder/GroupMember.pm
@@ -107,7 +107,7 @@ sub __DependsOn
Code => sub {
my %args = (@_);
my $group = $args{'TargetObject'};
- return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
+ return if ($args{'Shredder'}->GetState( Object => $group ) || 0) & (WIPED|IN_WIPING);
return if $group->id != $target_group_id; # ensure we're resolving the right group
return if $group->MembersObj->Count > 1;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list