(bug 28797) Fix ApiBase::parseMsg() to properly handle nested error arrays.
authorHappy-melon <happy-melon@users.mediawiki.org>
Sat, 7 May 2011 13:05:22 +0000 (13:05 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sat, 7 May 2011 13:05:22 +0000 (13:05 +0000)
includes/api/ApiBase.php

index 30e3a74..616f5a6 100644 (file)
@@ -1119,6 +1119,14 @@ abstract class ApiBase {
         */
        public function parseMsg( $error ) {
                $key = array_shift( $error );
+
+               // Check whether the error array was nested
+               // array( array( <code>, <params> ), array( <another_code>, <params> ) )
+               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 ) );
        }