Create UserGetRightsRemove hook
authorMR70 <mr7060@mail.com>
Sat, 22 Sep 2018 19:45:48 +0000 (19:45 +0000)
committerMR70 <mr7060@mail.com>
Mon, 24 Sep 2018 03:21:24 +0000 (03:21 +0000)
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
docs/hooks.txt
includes/user/User.php

index 7a3cb15..48b2be6 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 8223814..3c3f0a8 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 aaa7663..44cee50 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 ) );