From: Happy-melon Date: Sat, 7 May 2011 13:05:22 +0000 (+0000) Subject: (bug 28797) Fix ApiBase::parseMsg() to properly handle nested error arrays. X-Git-Tag: 1.31.0-rc.0~30351 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=3f4e0e2e749cbbfc48f8c728cd2667dd3f7a0021;p=lhc%2Fweb%2Fwiklou.git (bug 28797) Fix ApiBase::parseMsg() to properly handle nested error arrays. --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 30e3a74e7d..616f5a61ff 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1119,6 +1119,14 @@ abstract class ApiBase { */ public function parseMsg( $error ) { $key = array_shift( $error ); + + // Check whether the error array was nested + // array( array( , ), array( , ) ) + if( is_array( $key ) ){ + $error = $key; + $key = array_shift( $error ); + } + if ( isset( self::$messageMap[$key] ) ) { return array( 'code' => wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ), @@ -1126,6 +1134,7 @@ abstract class ApiBase { wfMsgReplaceArgs( self::$messageMap[$key]['info'], $error ) ); } + // If the key isn't present, throw an "unknown error" return $this->parseMsg( array( 'unknownerror', $key ) ); }