Merge "Ignore EXIF data in FormatMetadata::fetchExtendedMetadata()"
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index ba22e39..f17b874 100644 (file)
@@ -87,6 +87,7 @@ class ApiMain extends ApiBase {
                'options' => 'ApiOptions',
                'imagerotate' => 'ApiImageRotate',
                'revisiondelete' => 'ApiRevisionDelete',
+               'managetags' => 'ApiManageTags',
        );
 
        /**
@@ -190,19 +191,20 @@ class ApiMain extends ApiBase {
 
                $uselang = $this->getParameter( 'uselang' );
                if ( $uselang === 'user' ) {
-                       $uselang = $this->getUser()->getOption( 'language' );
-                       $uselang = RequestContext::sanitizeLangCode( $uselang );
-                       Hooks::run( 'UserGetLanguageObject', array( $this->getUser(), &$uselang, $this ) );
-               } elseif ( $uselang === 'content' ) {
-                       global $wgContLang;
-                       $uselang = $wgContLang->getCode();
-               }
-               $code = RequestContext::sanitizeLangCode( $uselang );
-               $this->getContext()->setLanguage( $code );
-               if ( !$this->mInternalMode ) {
-                       global $wgLang;
-                       $wgLang = $this->getContext()->getLanguage();
-                       RequestContext::getMain()->setLanguage( $wgLang );
+                       // Assume the parent context is going to return the user language
+                       // for uselang=user (see T85635).
+               } else {
+                       if ( $uselang === 'content' ) {
+                               global $wgContLang;
+                               $uselang = $wgContLang->getCode();
+                       }
+                       $code = RequestContext::sanitizeLangCode( $uselang );
+                       $this->getContext()->setLanguage( $code );
+                       if ( !$this->mInternalMode ) {
+                               global $wgLang;
+                               $wgLang = $this->getContext()->getLanguage();
+                               RequestContext::getMain()->setLanguage( $wgLang );
+                       }
                }
 
                $config = $this->getConfig();
@@ -553,6 +555,7 @@ class ApiMain extends ApiBase {
 
                        $response->header( "Access-Control-Allow-Origin: $originHeader" );
                        $response->header( 'Access-Control-Allow-Credentials: true' );
+                       $response->header( "Timing-Allow-Origin: $originHeader" ); # http://www.w3.org/TR/resource-timing/#timing-allow-origin
 
                        if ( !$preflight ) {
                                $response->header( 'Access-Control-Expose-Headers: MediaWiki-API-Error, Retry-After, X-Database-Lag' );
@@ -773,12 +776,14 @@ class ApiMain extends ApiBase {
 
                        $errMessage = array(
                                'code' => 'internal_api_error_' . get_class( $e ),
-                               'info' => $info,
-                       );
-                       ApiResult::setContent(
-                               $errMessage,
-                               $config->get( 'ShowExceptionDetails' ) ? "\n\n{$e->getTraceAsString()}\n\n" : ''
+                               'info' => '[' . MWExceptionHandler::getLogId( $e ) . '] ' . $info,
                        );
+                       if ( $config->get( 'ShowExceptionDetails' ) ) {
+                               ApiResult::setContent(
+                                       $errMessage,
+                                       MWExceptionHandler::getRedactedTraceAsString( $e )
+                               );
+                       }
                }
 
                // Remember all the warnings to re-add them later