From 618bc84b626d9085fc61cce47aa6d371953882c2 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 9 Jul 2013 15:45:46 -0400 Subject: [PATCH] Don't skip UserGetRights hook in addGroup/removeGroup The addGroup and removeGroup functions in User were reloading the cached mRights, but not calling the UserGetRights hook that is supposed to allow for extensions to modify the rights list. Instead, let's just null the cache so it will be reloaded next time something calls $user->getRights(). Note we still call $this->getEffectiveGroups( true ), though, to trigger that to recache. Change-Id: I81784917303b639bc7c22c726e9cbdb0d191e674 --- includes/User.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/User.php b/includes/User.php index bb61e80823..f2053711db 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2712,7 +2712,11 @@ class User { // 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 ) ); + + // Refresh the groups caches, and clear the rights cache so it will be + // refreshed on the next call to $this->getRights(). + $this->getEffectiveGroups( true ); + $this->mRights = null; $this->invalidateCache(); } @@ -2742,7 +2746,11 @@ class User { } $this->loadGroups(); $this->mGroups = array_diff( $this->mGroups, array( $group ) ); - $this->mRights = User::getGroupPermissions( $this->getEffectiveGroups( true ) ); + + // Refresh the groups caches, and clear the rights cache so it will be + // refreshed on the next call to $this->getRights(). + $this->getEffectiveGroups( true ); + $this->mRights = null; $this->invalidateCache(); } -- 2.20.1