From 9ea4764b2fbd84f229a559b709c54059f57118ad Mon Sep 17 00:00:00 2001 From: MR70 Date: Sat, 22 Sep 2018 19:45:48 +0000 Subject: [PATCH] Create UserGetRightsRemove hook This hook is created specifically for I379e17c. The purpose of this hook is to override UserGetRights hook and ensure that the removed rights will not be reinserted by the other callbacks. Change-Id: Id31b1f25f2eda012bd811f4b96aac525bc3251c4 --- RELEASE-NOTES-1.32 | 3 +++ docs/hooks.txt | 7 +++++++ includes/user/User.php | 1 + 3 files changed, 11 insertions(+) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 7a3cb1508e..48b2be6183 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -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 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 82238142b0..3c3f0a8db9 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/user/User.php b/includes/user/User.php index aaa7663948..44cee50207 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -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 ) ); -- 2.20.1