r95363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95362‎ | r95363 | r95364 >
Date:00:29, 24 August 2011
Author:johnduhart
Status:ok (Comments)
Tags:
Comment:
(bug 30444) Add variables user_name and user_groups for action createaccount. Patch by Beau
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -1523,7 +1523,12 @@
15241524 $vars->setVar( 'ACTION', 'createaccount' );
15251525
15261526 $name = Title::makeTitle( $row->rc_namespace, $row->rc_title )->getText();
1527 - $vars->setVar( 'user_name', $name );
 1527+ // Add user data if the account was created by a registered user
 1528+ if ( $row->rc_user && $name != $row->rc_user_text ) {
 1529+ $user = User::newFromName( $row->rc_user_text );
 1530+ $vars->addHolder( self::generateUserVars( $user ) );
 1531+ }
 1532+
15281533 $vars->setVar( 'accountname', $name );
15291534 return $vars;
15301535 }
Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php
@@ -105,6 +105,12 @@
106106 return false;
107107 }
108108 $vars = new AbuseFilterVariableHolder;
 109+ // Add variables only for a registered user, so IP addresses of
 110+ // new users won't be exposed
 111+ global $wgUser;
 112+ if ( $wgUser->getId() ) {
 113+ $vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) );
 114+ }
109115
110116 $vars->setVar( 'ACTION', 'createaccount' );
111117 $vars->setVar( 'ACCOUNTNAME', $user->getName() );

Sign-offs

UserFlagDate
Nikerabbitinspected10:59, 21 September 2011

Comments

#Comment by 😂 (talk | contribs)   20:35, 24 August 2011

Is there a reason you're introducing $wgUser here, rather than using the $user that's already on hand?

#Comment by Johnduhart (talk | contribs)   20:37, 24 August 2011

Yes, we want the user who created the account ($wgUser) instead of the account created ($user)

Status & tagging log