[Rt-commit] rt branch, 4.2/unowned-create, created. rt-4.0.8-803-ge6b6f33

Alex Vandiver alexmv at bestpractical.com
Mon Dec 3 19:36:21 EST 2012


The branch, 4.2/unowned-create has been created
        at  e6b6f338acd032323567f3c2b8a5c183bff4dba0 (commit)

- Log -----------------------------------------------------------------
commit e6b6f338acd032323567f3c2b8a5c183bff4dba0
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Dec 3 18:50:43 2012 -0500

    Remove a warning during creation of unowned tickets
    
    While 656b955 added the "Nobody" user to single-user groups during group
    creation, this combined poorly with 3911c5d and 3ae488e.  Namely,
    3911c5d causes $roles to contain RT->Nobody as a fallback for
    unparseable or non-existant values, and 3ae488e unilaterally then
    attempts to add that Nobody user to the single-user group -- which
    already contains it.  This causes unwarranted warnings about "already a
    member" during ticket creation for unowned tickets.
    
    Avoid these warnings by, during creation, skipping group membership
    addition if the principal is already present in the group.  This also
    avoids warnings in the case where a principal is provided twice to a
    role.

diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 927e662..ee5a8bc 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2487,10 +2487,12 @@ sub _AddRolesOnCreate {
         my $changed = 0;
 
         for my $role (keys %{$roles}) {
+            my $group = $self->RoleGroup($role);
             my @left;
             for my $principal (@{$roles->{$role}}) {
                 if ($acls{$role}->($principal)) {
-                    my ($ok, $msg) = $self->RoleGroup($role)->_AddMember(
+                    next if $group->HasMember($principal);
+                    my ($ok, $msg) = $group->_AddMember(
                         PrincipalId       => $principal->id,
                         InsideTransaction => 1,
                         RecordTransaction => 0,

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


More information about the Rt-commit mailing list