[Rt-commit] rt branch 4.4/shredder-replace-relations-check-field-value created. rt-4.4.5-32-ge2da402d78

BPS Git Server git at git.bestpractical.com
Tue Mar 29 20:28:38 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 4.4/shredder-replace-relations-check-field-value has been created
        at  e2da402d78a3e70fff11fb61dbb3dc69827b317f (commit)

- Log -----------------------------------------------------------------
commit e2da402d78a3e70fff11fb61dbb3dc69827b317f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 18 23:40:42 2021 +0800

    Only replace fields that match the to-be-wiped user
    
    Since records that match either Creator or LastUpdatedBy are processed
    here, we need to check if the current value is the to-be-wiped user
    before updating, otherwise we could update unrelated fields.
    
    E.g. a ticket is created by user "alice" and last updated by "root",
    previously shredding "alice" with replacement user "bob" would wrongly
    update "LastUpdatedBy" to "bob" too.

diff --git a/lib/RT/Shredder/Plugin/Users.pm b/lib/RT/Shredder/Plugin/Users.pm
index d8ea982994..046bf18a41 100644
--- a/lib/RT/Shredder/Plugin/Users.pm
+++ b/lib/RT/Shredder/Plugin/Users.pm
@@ -285,7 +285,9 @@ sub SetResolvers
             my $t =    $args{'TargetObject'};
             foreach my $method ( qw(Creator LastUpdatedBy) ) {
                 next unless $t->_Accessible( $method => 'read' );
-                $t->__Set( Field => $method, Value => $uid );
+                if ( $t->__Value($method) == $args{BaseObject}->Id ) {
+                    $t->__Set( Field => $method, Value => $uid );
+                }
             }
         };
         $args{'Shredder'}->PutResolver( BaseClass => 'RT::User', Code => $resolver );

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list