[Bps-public-commit] RT-Extension-MergeUsers branch, master, updated. 1.02_01-4-g9e301fd

? sunnavy sunnavy at bestpractical.com
Tue Dec 17 17:11:26 EST 2019


The branch, master has been updated
       via  9e301fd38ff12cd127e0c59d0e9f6081f002e1ef (commit)
      from  7265362a056318708b665123fae0e8c9ddb464ab (commit)

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

- Log -----------------------------------------------------------------
commit 9e301fd38ff12cd127e0c59d0e9f6081f002e1ef
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Dec 18 05:59:38 2019 +0800

    Check user merge info in deeper RT::Users search code
    
    Previously we checked merge info in RT::Users::Next call, which didn't
    cover the "ItemsArrayRef" call, so call of ItemsArrayRef could still
    return inaccurate user objects.
    
    e.g. merged users might still show up in "People" section on ticket
    display page, which calls ItemsArrayRef to get users.
    
    This commit puts the merge check in RT::Users::AddRecord instead, which
    could cover all the cases.

diff --git a/lib/RT/Extension/MergeUsers.pm b/lib/RT/Extension/MergeUsers.pm
index 3c088b8..bfbe908 100644
--- a/lib/RT/Extension/MergeUsers.pm
+++ b/lib/RT/Extension/MergeUsers.pm
@@ -411,36 +411,29 @@ sub NameAndEmail {
 package RT::Users;
 use RT::Users;
 
-sub Next {
-    my $self = shift;
-
-    my $user = $self->SUPER::Next(@_);
-    unless ($user and $user->id) {
-        $self->{seen_users} = undef;
-        return undef;
-    }
-
-
-
-    my ($effective_id) = $user->Attributes->Named("EffectiveId");
-    my $original_id = $user->Id;
-    if ($effective_id && $effective_id->Content && $effective_id->Content != $user->id) {
-        $user->LoadByCols(id =>$effective_id->Content);
+sub AddRecord {
+    my $self   = shift;
+    my $record = shift;
+    if ( $record->id ) {
+        my ($effective_id) = $record->Attributes->Named("EffectiveId");
+        my $original_id = $record->Id;
+        if ( $effective_id && $effective_id->Content && $effective_id->Content != $record->id ) {
+            my $user = RT::User->new( $record->CurrentUser );
+            $user->LoadByCols( id => $effective_id->Content );
+            if ( $user->id ) {
+                return if $self->{seen_users}{ $user->id };
+                $record = $user;
+            }
+        }
     }
-    return $self->Next() if ($user->Id and $self->{seen_users}->{$user->id}++);
-
-    # Failed to load the effective user record for some reason, so expose
-    # this user again.
-    $user->LoadByCols( Id => $original_id )
-        unless $user->Id;
-
-    return $user;
+    $self->{seen_users}{ $record->id }++;
+    return $self->SUPER::AddRecord($record);
 }
 
-sub GotoFirstItem {
+sub _DoSearch {
     my $self = shift;
-    $self->{seen_users} = undef;
-    $self->GotoItem(0);
+    delete $self->{seen_users};
+    return $self->SUPER::_DoSearch(@_);
 }
 
 

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


More information about the Bps-public-commit mailing list