Add the performer to the UserRightsChanged hook
authorKunal Mehta <legoktm@gmail.com>
Tue, 22 Sep 2015 17:58:20 +0000 (10:58 -0700)
committerKunal Mehta <legoktm@gmail.com>
Tue, 22 Sep 2015 17:58:20 +0000 (10:58 -0700)
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
includes/User.php
includes/specials/SpecialUserrights.php

index 0b9f249..7671e6e 100644 (file)
@@ -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).
index e3636a0..22c90cd 100644 (file)
@@ -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
index 5c4e9de..e91c0bd 100644 (file)
@@ -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" );