Why:
- We want to make sure that the top-level redirect fires for temporary
accounts which were created in an edit attempt, but did not yet save
an edit
What:
- In EditPage and ApiEditPage, perform the redirect if there is a saved
temp user as part of the current process, or if the user account is a
temporary one and it has no edits. Note that this means the top-level
redirect would be performed if a temp user creates a first edit on a
non-home wiki:
- logged out user makes a failed attempt on wiki A, temp account is
created
- same user makes a successful edit on wiki A, redirect hook fires
- same user visits wiki B and makes a succesful edit, redirect hook
fires
Note:
- We could consider setting a query parameter like
`createdinrequest=1` to signal to TempUserCreatedRedirect
implementations that the temporary account was created in the current
request, and did not exist earlier. But I am not sure if we have a use
case for needing that, so have left it out of this patch.
Bug: T359405
Change-Id: If4b8c561383f993606c0ba565591871195a1f8c2
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Hook;
|
|
|
|
use MediaWiki\Session\Session;
|
|
use MediaWiki\User\UserIdentity;
|
|
|
|
/**
|
|
* This is a hook handler interface, see docs/Hooks.md.
|
|
* Use the hook name "TempUserCreatedRedirect" to register handlers implementing this interface.
|
|
*
|
|
* @stable to implement
|
|
* @ingroup Hooks
|
|
*/
|
|
interface TempUserCreatedRedirectHook {
|
|
/**
|
|
* This hook is called after an action causes a temporary user to be
|
|
* created or after the first successful edit for a temporary account.
|
|
* The handler may modify the redirect URL.
|
|
*
|
|
* To differentiate between invocations of this hook where a) the account
|
|
* was created in the current request and b) the account existed, but made
|
|
* a first successful edit, one can examine the registration date of the
|
|
* account.
|
|
*
|
|
* @since 1.39
|
|
*
|
|
* @param Session $session
|
|
* @param UserIdentity $user
|
|
* @param string $returnTo The prefixed DB key of the title to redirect to
|
|
* @param string $returnToQuery An extra query part
|
|
* @param string $returnToAnchor Either an empty string or a fragment beginning with "#"
|
|
* @param string &$redirectUrl The URL to redirect to
|
|
* @return bool|null
|
|
*/
|
|
public function onTempUserCreatedRedirect(
|
|
Session $session,
|
|
UserIdentity $user,
|
|
string $returnTo,
|
|
string $returnToQuery,
|
|
string $returnToAnchor,
|
|
&$redirectUrl
|
|
);
|
|
}
|