[Rt-commit] rt branch, 4.4/shredder-replace-relations-check-field-value, created. rt-4.4.4-448-g6a92961290

? sunnavy sunnavy at bestpractical.com
Tue May 18 11:50:45 EDT 2021


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

- Log -----------------------------------------------------------------
commit 6a92961290f438f60b33131865737a3d4cd298e3
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 a503e0d941..07121f4ff9 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 );

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


More information about the rt-commit mailing list