Merge "Create UserGetRightsRemove hook"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 30 Sep 2018 18:12:50 +0000 (18:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 30 Sep 2018 18:12:50 +0000 (18:12 +0000)
RELEASE-NOTES-1.32
docs/hooks.txt
includes/user/User.php

index f50ab00..d875017 100644 (file)
@@ -93,6 +93,9 @@ production.
   This action should be considered deprecated and should not be used directly.
 * Extensions overriding ContentHandler::getUndoContent() will need to be
   updated for the changed method signature.
+* Added a new hook, 'UserGetRightsRemove', which can be used to remove rights
+  from user. Unlike the 'UserGetRights' it will ensure that removed rights
+  will not be reinserted.
 
 === External library changes in 1.32 ===
 
index 063bbe5..d82f56e 100644 (file)
@@ -3783,6 +3783,13 @@ $context: IContextSource object
 $user: User to get rights for
 &$rights: Current rights
 
+'UserGetRightsRemove': Called in User::getRights(). This hook override
+the UserGetRights hook. It can be used to remove rights from user
+and ensure that will not be reinserted by the other hook callbacks
+therefore this hook should not be used to add any rights, use UserGetRights instead.
+$user: User to get rights for
+&$rights: Current rights
+
 'UserGroupsChanged': Called after user groups are changed.
 $user: User whose groups changed
 $added: Groups added
index 89fd99c..a29fbf8 100644 (file)
@@ -3540,6 +3540,7 @@ class User implements IDBAccessObject, UserIdentity {
                                }
                        }
 
+                       Hooks::run( 'UserGetRightsRemove', [ $this, &$this->mRights ] );
                        // Force reindexation of rights when a hook has unset one of them
                        $this->mRights = array_values( array_unique( $this->mRights ) );