From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- includes/api/ApiCreateAccount.php | 48 +++++++++++++-------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'includes/api/ApiCreateAccount.php') diff --git a/includes/api/ApiCreateAccount.php b/includes/api/ApiCreateAccount.php index 2ce532b9..455540b4 100644 --- a/includes/api/ApiCreateAccount.php +++ b/includes/api/ApiCreateAccount.php @@ -29,9 +29,12 @@ */ class ApiCreateAccount extends ApiBase { public function execute() { - // If we're in JSON callback mode, no tokens can be obtained - if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) { - $this->dieUsage( 'Cannot create account when using a callback', 'aborted' ); + // If we're in a mode that breaks the same-origin policy, no tokens can + // be obtained + if ( $this->lacksSameOriginSecurity() ) { + $this->dieUsage( + 'Cannot create account when the same-origin policy is not applied', 'aborted' + ); } // $loginForm->addNewaccountInternal will throw exceptions @@ -83,7 +86,7 @@ class ApiCreateAccount extends ApiBase { $loginForm = new LoginForm(); $loginForm->setContext( $context ); - wfRunHooks( 'AddNewAccountApiForm', array( $this, $loginForm ) ); + Hooks::run( 'AddNewAccountApiForm', array( $this, $loginForm ) ); $loginForm->load(); $status = $loginForm->addNewaccountInternal(); @@ -113,7 +116,7 @@ class ApiCreateAccount extends ApiBase { // Save settings (including confirmation token) $user->saveSettings(); - wfRunHooks( 'AddNewAccount', array( $user, $params['mailpassword'] ) ); + Hooks::run( 'AddNewAccount', array( $user, $params['mailpassword'] ) ); if ( $params['mailpassword'] ) { $logAction = 'byemail'; @@ -149,9 +152,9 @@ class ApiCreateAccount extends ApiBase { $warnings = $status->getErrorsByType( 'warning' ); if ( $warnings ) { foreach ( $warnings as &$warning ) { - $apiResult->setIndexedTagName( $warning['params'], 'param' ); + ApiResult::setIndexedTagName( $warning['params'], 'param' ); } - $apiResult->setIndexedTagName( $warnings, 'warning' ); + ApiResult::setIndexedTagName( $warnings, 'warning' ); $result['warnings'] = $warnings; } } else { @@ -160,15 +163,11 @@ class ApiCreateAccount extends ApiBase { } // Give extensions a chance to modify the API result data - wfRunHooks( 'AddNewAccountApiResult', array( $this, $loginForm, &$result ) ); + Hooks::run( 'AddNewAccountApiResult', array( $this, $loginForm, &$result ) ); $apiResult->addValue( null, 'createaccount', $result ); } - public function getDescription() { - return 'Create a new user account.'; - } - public function mustBePosted() { return true; } @@ -204,27 +203,12 @@ class ApiCreateAccount extends ApiBase { ); } - public function getParamDescription() { - $p = $this->getModulePrefix(); - - return array( - 'name' => 'Username', - 'password' => "Password (ignored if {$p}mailpassword is set)", - 'domain' => 'Domain for external authentication (optional)', - 'token' => 'Account creation token obtained in first request', - 'email' => 'Email address of user (optional)', - 'realname' => 'Real name of user (optional)', - 'mailpassword' => 'If set to any value, a random password will be emailed to the user', - 'reason' => 'Optional reason for creating the account to be put in the logs', - 'language' - => 'Language code to set as default for the user (optional, defaults to content language)' - ); - } - - public function getExamples() { + protected function getExamplesMessages() { return array( - 'api.php?action=createaccount&name=testuser&password=test123', - 'api.php?action=createaccount&name=testmailuser&mailpassword=true&reason=MyReason', + 'action=createaccount&name=testuser&password=test123' + => 'apihelp-createaccount-example-pass', + 'action=createaccount&name=testmailuser&mailpassword=true&reason=MyReason' + => 'apihelp-createaccount-example-mail', ); } -- cgit v1.2.2