[Bps-public-commit] RT-Extension-MergeUsers branch, shredder-compatibility, updated. 0.12-7-g1659224

Jim Brandt jbrandt at bestpractical.com
Thu Jun 19 10:29:02 EDT 2014


The branch, shredder-compatibility has been updated
       via  16592241990a935973236dae98e6d0ea1125b43f (commit)
      from  9a8b2e842961e140d75617148a58b54ab276f13f (commit)

Summary of changes:
 lib/RT/Extension/MergeUsers.pm | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit 16592241990a935973236dae98e6d0ea1125b43f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Jun 19 10:24:27 2014 -0400

    Don't copy code from the original BeforeWipeout
    
    Save the original and call it so MergeUsers will pick up any
    future changes to RT::User::BeforeWipeout.

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index 873bc9d..538dac8 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -357,26 +357,26 @@ sub NameAndEmail {
     }
 }
 
-sub BeforeWipeout {
-    my $self = shift;
-    if( $self->Name =~ /^(RT_System|Nobody)$/ ) {
-        RT::Shredder::Exception::Info->throw('SystemObject');
-    }
-
-    # Check to see if this user has any other users merged into it
-    # Unmerge any merged users to break the connection to this
-    # soon-to-be-shredded user.
-    # The MergedUsers attribute on this user will be removed by Shredder.
-
-    my $merged_users = $self->GetMergedUsers;
-    foreach my $user_id ( @{$merged_users->Content} ){
-        my $merged_user = RT::User->new(RT->SystemUser);
-        $merged_user->LoadOriginal( id => $user_id );
-        my ($id, $result) = $merged_user->UnMerge();
-        RT::Logger->info($result);
-    }
+{
+    my $orig = RT::User->can('BeforeWipeout');
+    *RT::User::BeforeWipeout = sub {
+        my $self = shift;
+
+        # Check to see if this user has any other users merged into it
+        # Unmerge any merged users to break the connection to this
+        # soon-to-be-shredded user.
+        # The MergedUsers attribute on this user will be removed by Shredder.
+
+        my $merged_users = $self->GetMergedUsers;
+        foreach my $user_id ( @{$merged_users->Content} ){
+            my $merged_user = RT::User->new(RT->SystemUser);
+            $merged_user->LoadOriginal( id => $user_id );
+            my ($id, $result) = $merged_user->UnMerge();
+            RT::Logger->info($result);
+        }
 
-    return $self->SUPER::BeforeWipeout( @_ );
+        return $orig->($self, @_);
+    };
 }
 
 package RT::Users;

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


More information about the Bps-public-commit mailing list