Add Status outparam for AbortNewAccount hook to fix API error handling
authorBrion Vibber <brion@pobox.com>
Fri, 17 Jan 2014 20:26:41 +0000 (12:26 -0800)
committerBrion Vibber <brion@pobox.com>
Thu, 23 Jan 2014 18:02:50 +0000 (10:02 -0800)
commitc8e3c424f9ddd929b4ddfae61f39f94b2894b467
treeed83109b9150ebd8c1c94427a6586f224111efb5
parent2fc330138eae41dde63ef0fd935f7b1fe2763c8d
Add Status outparam for AbortNewAccount hook to fix API error handling

With this fix and relevant fix for ConfirmEdit in, an API account creation
attempt that fails the captcha check will return a much cleaner error such as:

{
  'error': {
    'code': 'captcha-createaccount-fail',
    'info': 'Incorrect or missing CAPTCHA.'
  }
}

Abort hooks that use the old interface and send a text message will now
be reported with the generic 'createaccount-hook-abort' message code, with the
string passed back intact.

Previously, the returned result would list the contents of the message
_as_ the error code, making it hard for a client to determine the error.

'AbortNewAccount' hook clients can add a '&$status=null' function paramater
on their signature, and along with the back-compat message parameter
you can set something like:

  $msg = wfMessage( 'captcha-createaccount-fail' )->text(); // back-compat
  $status = Status::newFatal( 'captcha-createaccount-fail' ); // new

This is done for ConfirmEdit in If9cc08e

Bug: 60008
Change-Id: I6ae34c00d1051d34363b6d654424be17dcb1ea30
docs/hooks.txt
includes/specials/SpecialUserlogin.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messageTypes.inc