Page MenuHomePhabricator

Execute MediaWiki Hook 'AddNewAccount' when new account is added
Closed, ResolvedPublic

Description

Add new account hook (as found in SpecialUserlogin.php

MediaWiki has a hook 'AddNewAccount' that is executed when a new account is added. This hook should also be executed when Extension:OpenID creates a new account.

One line adds functionality identical to other account adds as found in SpecialUserlogin.php line 189


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz21711

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:56 PM
bzimport set Reference to bz21711.

Maybe a hook should be added in the backend (User::addToDatabase()) instead?

(In reply to comment #1)

Maybe a hook should be added in the backend (User::addToDatabase()) instead?

Possible, but it is handled in includes/specials/SpecialUserLogin.php always appearing right before addNewUserLogEntry function call, e.g.:

wfRunHooks( 'AddNewAccount', array( $u, false ) );
$u->addNewUserLogEntry();

This is used several times in that script, and I thought might be best to continue the existing practice into OpenID.

However, this question brings up another, to wit, should other login/create account hooks be included in the OpenID extension? And if so, which ones? Will look into this and invite others to do so, adding to this bug?

sergey.chernyshev wrote:

I have a feeling that hooks should be in the core unless their users extend OpenID specifically.

(In reply to comment #3)

I have a feeling that hooks should be in the core unless their users extend
OpenID specifically.

Sergey, agreed, but that depend on the definition of "core". If "core" includes standard Special pages like SpecialUserLogin, this hook is already included in there, thrice as a matter of fact, once in addNewAccountMailPassword() and twice in addNewAccount(), all 3 times immediately prior to addNewUserLogEntry() method. The problem is that OpenID extension bypasses many of the checks and functional processes of the standard login and uses primatives. This goes back to the question I discussed with you before about whether the two should be merged - I'd personally like to see this functionality included in the "core" and even used on WP.

In this case I use this particular hook for the exact same reason - to provide functionality when a new user registers. Other hooks that have relevance for OpenID would be:

AbortNewAccount - http://www.mediawiki.org/wiki/Manual:Hooks/AbortNewAccount
AbortLogin - http://www.mediawiki.org/wiki/Manual:Hooks/AbortLogin
AuthPluginAutoCreate - http://www.mediawiki.org/wiki/Manual:Hooks/AuthPluginAutoCreate
LoginAuthenticateAudit - http://www.mediawiki.org/wiki/Manual:Hooks/LoginAuthenticateAudit
UserLoginMailPassword - http://www.mediawiki.org/wiki/Manual:Hooks/UserLoginMailPassword
User::mailPasswordInternal - http://www.mediawiki.org/wiki/Manual:Hooks/mailPasswordInternal
UserLoginComplete - http://www.mediawiki.org/wiki/Manual:Hooks/UserLoginComplete
UserCreateForm - http://www.mediawiki.org/wiki/Manual:Hooks/UserCreateForm

Maybe the question is really should a different hook be provided that distinguishes it from standard logins, but much of this functionality is useful in both - and serves the exact same purpose in both generally.

sergey.chernyshev wrote:

I see your point and I think merging OpenID support into core is the right thing to do, but it's probably not my call to make.

I think it'll make sense to include some of those hooks (starting with AddNewAccount) into OpenID, but not sure if all of them should be included. It's possible that login needs to be re-architected to be "properly" extended considering that OpenID provides only portion of the process.

Do you have a specific implementation that requires any of those hooks to be added to OpenID?

Added a hook as suggested. Added a third parameter to the hook $byOpenID = true

SpecialOpenIDLogin.body.php:

new user account: not opened by mail, opened by OpenID

wfRunHooks( 'AddNewAccount', array( $user, false, true ) );

http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount
fixed in r88758

UPDATE/CORRECTION of comment #7

Added a hook as suggested.
SpecialOpenIDLogin.body.php:

  1. new user account: not opened by mail, opened by OpenID wfRunHooks( 'AddNewAccount', array( $user, false ) );