Brion VIBBER has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/53793


Change subject: Add APICreateAccountBeforeCreate hook for action=apicreate to 
connect to ConfirmEdit plugins
......................................................................

Add APICreateAccountBeforeCreate hook for action=apicreate to connect to 
ConfirmEdit plugins

Change-Id: I10d68a5f52925a9cc99f89a2e6baefea8bf13654
---
M docs/hooks.txt
M includes/api/ApiCreateAccount.php
2 files changed, 16 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/93/53793/1

diff --git a/docs/hooks.txt b/docs/hooks.txt
index 3670cbe..2f738e0 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -371,6 +371,11 @@
 &$module: ApiBase Module object
 &$properties: Array of properties
 
+'APICreateAccountBeforeCreate': Before creating a user with 
api.php?action=createuser,
+after processing request parameters. Return false to let the request fail, 
returning
+an error message or an <createuser result="Failure"> tag if $resultArr was 
filled.
+&$resultArr : data in this array will be added to the API result
+
 'APIQueryAfterExecute': After calling the execute() method of an
 action=query submodule. Use this to extend core API modules.
 &$module: Module object
diff --git a/includes/api/ApiCreateAccount.php 
b/includes/api/ApiCreateAccount.php
index 55c60cc..e982d03 100644
--- a/includes/api/ApiCreateAccount.php
+++ b/includes/api/ApiCreateAccount.php
@@ -44,6 +44,7 @@
                $params = $this->extractRequestParams();
 
                $result = array();
+               $apiResult = $this->getResult();
 
                // Init session if necessary
                if ( session_id() == '' ) {
@@ -52,6 +53,16 @@
 
                if( $params['mailpassword'] && !$params['email'] ) {
                        $this->dieUsageMsg( 'noemail' );
+               }
+
+               // Run hooks
+               // Handle APICreateAccountBeforeCreate parameters
+               $r = array();
+               if ( !wfRunHooks( 'APICreateAccountBeforeCreate', array( &$r ) 
) ) {
+                       if ( count( $r ) ) {
+                               $apiResult->addValue( null, 
$this->getModuleName(), $r );
+                               return;
+                       }
                }
 
                $context = new DerivativeContext( $this->getContext() );
@@ -117,8 +128,6 @@
                        $result['userid'] = $user->getId();
                        $result['token'] = $user->getToken();
                }
-
-               $apiResult = $this->getResult();
 
                if( $status->hasMessage( 'sessionfailure' ) || 
$status->hasMessage( 'nocookiesfornew' ) ) {
                        // Token was incorrect, so add it to result, but don't 
throw an exception

-- 
To view, visit https://gerrit.wikimedia.org/r/53793
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I10d68a5f52925a9cc99f89a2e6baefea8bf13654
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to