[Rt-commit] rt branch, 4.2/shredder-assets, created. rt-4.2.10-224-gdd2a4ca

Alex Vandiver alexmv at bestpractical.com
Thu Mar 26 15:02:39 EDT 2015


The branch, 4.2/shredder-assets has been created
        at  dd2a4ca2e17b1bf04ef6144766804404832452f9 (commit)

- Log -----------------------------------------------------------------
commit 60e0752809c813de6eab7cc8b7558601faa3758e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Mar 26 14:54:38 2015 -0400

    Generalize Owner logic in Shredder to any Single role group
    
    Extensions, like Assets, may add other relations which are Single role
    groups -- that is, they are expected to always have one member in them,
    even if that value is the Nobody user.
    
    Switch from hard-coded checks on Owner to working on all Single role
    groups; this allows users to be shredded in systems with Assets, and the
    GroupMembers and CachedGroupMembers tables to remain consistent.

diff --git a/lib/RT/GroupMember.pm b/lib/RT/GroupMember.pm
index 6fc6002..1049a53 100644
--- a/lib/RT/GroupMember.pm
+++ b/lib/RT/GroupMember.pm
@@ -531,8 +531,8 @@ sub __DependsOn {
     my $group = $self->GroupObj->Object;
     # XXX: If we delete member of the ticket owner role group then we should also
     # fix ticket object, but only if we don't plan to delete group itself!
-    unless( ($group->Name || '') eq 'Owner' &&
-        ($group->Domain || '') eq 'RT::Ticket-Role' ) {
+    my $class = $group->RoleClass;
+    unless( $class and $class->Role($group->Name)->{Single}) {
         return $self->SUPER::__DependsOn( %args );
     }
 
@@ -551,15 +551,15 @@ sub __DependsOn {
             my $group = $args{'TargetObject'};
             return if $args{'Shredder'}->GetState( Object => $group )
                 & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::IN_WIPING);
-            return unless ($group->Name || '') eq 'Owner';
-            return unless ($group->Domain || '') eq 'RT::Ticket-Role';
+            my $class = $group->RoleClass or return;
+            return unless $class->Role($group->Name)->{Single};
 
             return if $group->MembersObj->Count > 1;
 
             my $group_member = $args{'BaseObject'};
 
             if( $group_member->MemberObj->id == RT->Nobody->id ) {
-                RT::Shredder::Exception->throw( "Couldn't delete Nobody from owners role group" );
+                RT::Shredder::Exception->throw( "Couldn't delete Nobody from @{[$group->Name]} role group" );
             }
 
             my( $status, $msg ) = $group->AddMember( RT->Nobody->id );

commit dd2a4ca2e17b1bf04ef6144766804404832452f9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Mar 26 14:56:47 2015 -0400

    Remove SetWatcher rows in transaction history as well
    
    f2f00cf1 added SetWatcher transactions, for Single role groups; they
    remain unused (and hidden) in core, as that commit describes.  Thus,
    that the Shredder did not clean up their transactions (leaving dangling
    references) has remained hidden, irrelevant except for when non-Ticket
    objects are involved.
    
    Search for and remove SetWatcher transactions when a Principal is
    removed; this allows object history to be consistent after a user has
    been shredded.

diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
index 8cf509d..0492f7b 100644
--- a/lib/RT/Principal.pm
+++ b/lib/RT/Principal.pm
@@ -860,6 +860,12 @@ sub __DependsOn {
         $objs->Limit( FIELD => 'Type', VALUE => $type );
         push( @$list, $objs );
     }
+    for my $column ( qw(OldValue NewValue) ) {
+        my $objs = RT::Transactions->new( $self->CurrentUser );
+        $objs->Limit( FIELD => $column, VALUE => $self->Id );
+        $objs->Limit( FIELD => 'Type', VALUE => 'SetWatcher' );
+        push( @$list, $objs );
+    }
 
     $deps->_PushDependencies(
         BaseObject => $self,

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


More information about the rt-commit mailing list