Merge "Add attributes parameter to ShowSearchHitTitle"
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index 1415640..edc1a3e 100644 (file)
@@ -125,7 +125,6 @@ class ApiMain extends ApiBase {
                'none' => 'ApiFormatNone',
        ];
 
-       // @codingStandardsIgnoreStart String contenation on "msg" not allowed to break long line
        /**
         * List of user roles that are specifically relevant to the API.
         * [ 'right' => [ 'msg'    => 'Some message with a $1',
@@ -142,7 +141,6 @@ class ApiMain extends ApiBase {
                        'params' => [ ApiBase::LIMIT_SML2, ApiBase::LIMIT_BIG2 ]
                ]
        ];
-       // @codingStandardsIgnoreEnd
 
        /**
         * @var ApiFormatBase
@@ -1054,13 +1052,14 @@ class ApiMain extends ApiBase {
                        if ( ( $e instanceof DBQueryError ) && !$config->get( 'ShowSQLErrors' ) ) {
                                $params = [ 'apierror-databaseerror', WebRequest::getRequestId() ];
                        } else {
-                               $params = [
-                                       'apierror-exceptioncaught',
-                                       WebRequest::getRequestId(),
-                                       $e instanceof ILocalizedException
-                                               ? $e->getMessageObject()
-                                               : wfEscapeWikiText( $e->getMessage() )
-                               ];
+                               if ( $e instanceof ILocalizedException ) {
+                                       $msg = $e->getMessageObject();
+                               } elseif ( $e instanceof MessageSpecifier ) {
+                                       $msg = Message::newFromSpecifier( $e );
+                               } else {
+                                       $msg = wfEscapeWikiText( $e->getMessage() );
+                               }
+                               $params = [ 'apierror-exceptioncaught', WebRequest::getRequestId(), $msg ];
                        }
                        $messages[] = ApiMessage::create( $params, $code );
                }