From bdf3f3e2d75c3b9a4ec1e62c1cf51821b9077bea Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 22 Sep 2015 10:58:20 -0700 Subject: [PATCH] Add the performer to the UserRightsChanged hook This allows extensions (e.g. Echo) to detect who made the change without relying upon $wgUser. It also allows for differentiation between autopromotion entries which will pass in `false` as the performer. Change-Id: Idebd78b54dcea1bdc84c83f402e87b240ab4ade1 --- docs/hooks.txt | 1 + includes/User.php | 2 +- includes/specials/SpecialUserrights.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 0b9f249e37..7671e6e3f5 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3209,6 +3209,7 @@ $user: User to get rights for $user: User whose groups changed $added: Groups added $removed: Groups removed +$performer: User who performed the change, false if via autopromotion 'UserIsBlockedFrom': Check if a user is blocked from a specific page (for specific block exemptions). diff --git a/includes/User.php b/includes/User.php index e3636a0d59..22c90cdd16 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1431,7 +1431,7 @@ class User implements IDBAccessObject { $this->addGroup( $group ); } // update groups in external authentication database - Hooks::run( 'UserGroupsChanged', array( $this, $toPromote, array() ) ); + Hooks::run( 'UserGroupsChanged', array( $this, $toPromote, array(), false ) ); $wgAuth->updateExternalDBGroups( $this, $toPromote ); $newGroups = array_merge( $oldGroups, $toPromote ); // all groups diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 5c4e9defb9..e91c0bde18 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -269,7 +269,7 @@ class UserrightsPage extends SpecialPage { $user->invalidateCache(); // update groups in external authentication database - Hooks::run( 'UserGroupsChanged', array( $user, $add, $remove ) ); + Hooks::run( 'UserGroupsChanged', array( $user, $add, $remove, $this->getUser() ) ); $wgAuth->updateExternalDBGroups( $user, $add, $remove ); wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" ); -- 2.20.1