API: Make uselang=user the default
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index c9e898c..10a99c9 100644 (file)
@@ -192,12 +192,16 @@ class ApiMain extends ApiBase {
                        $uselang = $this->getUser()->getOption( 'language' );
                        $uselang = RequestContext::sanitizeLangCode( $uselang );
                        wfRunHooks( '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 = RequestContext::getMain()->getLanguage();
+                       $wgLang = $this->getContext()->getLanguage();
+                       RequestContext::getMain()->setLanguage( $wgLang );
                }
 
                $config = $this->getConfig();
@@ -309,7 +313,7 @@ class ApiMain extends ApiBase {
                        // then there's an appropriate Vary header set by whatever set
                        // their non-default language.
                        wfDebug( __METHOD__ . ": downgrading cache mode 'public' to " .
-                          "'anon-public-user-private' due to uselang=user\n" );
+                               "'anon-public-user-private' due to uselang=user\n" );
                        $mode = 'anon-public-user-private';
                }
 
@@ -1120,8 +1124,6 @@ class ApiMain extends ApiBase {
         * @return array
         */
        public function getAllowedParams() {
-               global $wgContLang;
-
                return array(
                        'action' => array(
                                ApiBase::PARAM_DFLT => 'help',
@@ -1150,13 +1152,13 @@ class ApiMain extends ApiBase {
                        'curtimestamp' => false,
                        'origin' => null,
                        'uselang' => array(
-                               ApiBase::PARAM_DFLT => $wgContLang->getCode(),
+                               ApiBase::PARAM_DFLT => 'user',
                        ),
                );
        }
 
        /** @see ApiBase::getExamplesMessages() */
-       public function getExamplesMessages() {
+       protected function getExamplesMessages() {
                return array(
                        'action=help'
                                => 'apihelp-help-example-main',