From b5c30abacb70cf821d13379ce4fca651c31fc4e5 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sat, 5 Mar 2011 03:35:49 +0000 Subject: [PATCH] (bug 27862; follow-up r77714) Make emailuser api module not freak out when SpecialEmailUser returns a status object instead of true. --- RELEASE-NOTES | 1 + includes/api/ApiEmailUser.php | 11 +++++++++++ includes/specials/SpecialEmailuser.php | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 513e299553..9c92368e1a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -203,6 +203,7 @@ PHP if you have not done so prior to upgrading MediaWiki. * (bug 27688) Simplify queries to list user block information * (bug 27708) list=users does not have a property to return user id * (bug 27715) imageinfo didn't respect revdelete +* (bug 27862) Useremail module didn't properly return success on success. === Languages updated in 1.18 === diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 2c7df4e982..55188b96a0 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -63,6 +63,17 @@ class ApiEmailUser extends ApiBase { 'CCMe' => $params['ccme'], ); $retval = SpecialEmailUser::submit( $data ); + + if ( $retval instanceof Status ) { + // SpecialEmailUser sometimes returns a status + // sometimes it doesn't. + if ( $retval->isGood() ) { + $retval = true; + } else { + $retval = $retval->getErrorsArray(); + } + } + if ( $retval === true ) { $result = array( 'result' => 'Success' ); } else { diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 77c91de136..6127122710 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -221,7 +221,8 @@ class SpecialEmailUser extends UnlistedSpecialPage { * getPermissionsError(). It is probably also a good * idea to check the edit token and ping limiter in advance. * - * @return Mixed: True on success, String on error + * @return Mixed: Status object, or potentially a String on error + * or maybe even true on success if anything uses the EmailUser hook. */ public static function submit( $data ) { global $wgUser, $wgUserEmailUseReplyTo; -- 2.20.1