X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialUserrights.php;h=a5edcb02caa2c6c005ba33cdf1ed0f4712c9ca39;hb=21e83e5d562b7a0efaa1afe46574c8d8cd0f51f5;hp=892ff5bc959f5a30bb2dca708811351d0eccb06c;hpb=aeec4a421931dd9c2b21a35aef36a94e7e70a8f8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 892ff5bc95..a5edcb02ca 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -106,7 +106,7 @@ class UserrightsPage extends SpecialPage { } } - if ( User::getCanonicalName( $this->mTarget ) == $user->getName() ) { + if ( User::getCanonicalName( $this->mTarget ) === $user->getName() ) { $this->isself = true; } @@ -218,7 +218,7 @@ class UserrightsPage extends SpecialPage { /** * Save user groups changes in the database. * - * @param User $user + * @param User|UserRightsProxy $user * @param array $add Array of groups to add * @param array $remove Array of groups to remove * @param string $reason Reason for group change @@ -228,7 +228,7 @@ class UserrightsPage extends SpecialPage { global $wgAuth; // Validate input set... - $isself = ( $user->getName() == $this->getUser()->getName() ); + $isself = $user->getName() == $this->getUser()->getName(); $groups = $user->getGroups(); $changeable = $this->changeableGroups(); $addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() ); @@ -244,18 +244,22 @@ class UserrightsPage extends SpecialPage { $oldGroups = $user->getGroups(); $newGroups = $oldGroups; - // remove then add groups + // Remove then add groups if ( $remove ) { - $newGroups = array_diff( $newGroups, $remove ); - foreach ( $remove as $group ) { - $user->removeGroup( $group ); + foreach ( $remove as $index => $group ) { + if ( !$user->removeGroup( $group ) ) { + unset($remove[$index]); + } } + $newGroups = array_diff( $newGroups, $remove ); } if ( $add ) { - $newGroups = array_merge( $newGroups, $add ); - foreach ( $add as $group ) { - $user->addGroup( $group ); + foreach ( $add as $index => $group ) { + if ( !$user->addGroup( $group ) ) { + unset($add[$index]); + } } + $newGroups = array_merge( $newGroups, $add ); } $newGroups = array_unique( $newGroups );