User::addGroup could cause duplicate groups
authorNiklas Laxström <niklas.laxstrom@gmail.com>
Wed, 3 Apr 2013 12:17:32 +0000 (12:17 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 23 Apr 2013 11:52:43 +0000 (11:52 +0000)
Use array_unique to avoid this case.

Bug: 46844
Change-Id: I14eb6e5a5333d887d71d545e42570493437dd320

includes/User.php

index cb5ad7a..dd6407d 100644 (file)
@@ -2668,6 +2668,9 @@ class User {
                }
                $this->loadGroups();
                $this->mGroups[] = $group;
+               // In case loadGroups was not called before, we now have the right twice.
+               // Get rid of the duplicate.
+               $this->mGroups = array_unique( $this->mGroups );
                $this->mRights = User::getGroupPermissions( $this->getEffectiveGroups( true ) );
 
                $this->invalidateCache();