Bug 36453 - Provide the git info on action=query&meta=siteinfo
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 0ba88bb..38e37c0 100644 (file)
@@ -121,9 +121,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['dbtype'] = $GLOBALS['wgDBtype'];
                $data['dbversion'] = $this->getDB()->getServerVersion();
 
-               $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
-               if ( $svn ) {
-                       $data['rev'] = $svn;
+               $git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
+               if ( $git ) {
+                       $data['git-hash'] = $git;
+               } else {
+                       $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
+                       if ( $svn ) {
+                               $data['rev'] = $svn;
+                       }
                }
 
                // 'case-insensitive' option is reserved for future
@@ -142,6 +147,15 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['fallback'] = $fallbacks;
                $this->getResult()->setIndexedTagName( $data['fallback'], 'lang' );
 
+               if( $wgContLang->hasVariants() ) {
+                       $variants = array();
+                       foreach( $wgContLang->getVariants() as $code ) {
+                               $variants[] = array( 'code' => $code );
+                       }
+                       $data['variants'] = $variants;
+                       $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );
+               }
+
                if ( $wgContLang->isRTL() ) {
                        $data['rtl'] = '';
                }
@@ -177,6 +191,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data['misermode'] = '';
                }
 
+               $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
+
                wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
 
                return $this->getResult()->addValue( 'query', $property, $data );
@@ -204,6 +220,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( MWNamespace::isContent( $ns ) ) {
                                $data[$ns]['content'] = '';
                        }
+
+                       if ( MWNamespace::isNonincludable( $ns ) ) {
+                               $data[$ns]['nonincludable'] = '';
+                       }
                }
 
                $this->getResult()->setIndexedTagName( $data, 'ns' );
@@ -270,13 +290,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                $params = $this->extractRequestParams();
-               $langCode = isset( $params['inlanguagecode '] ) ? $params['inlanguagecode '] : '';
-
-               if( $langCode ) {
-                       $langNames = Language::getTranslatedLanguageNames( $langCode );
-               } else {
-                       $langNames = Language::getLanguageNames();
-               }
+               $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
+               $langNames = Language::fetchLanguageNames( $langCode );
 
                $getPrefixes = Interwiki::getAllPrefixes( $local );
                $data = array();
@@ -292,12 +307,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( isset( $langNames[$prefix] ) ) {
                                $val['language'] = $langNames[$prefix];
                        }
-                       $val['url'] = wfExpandUrl( $row->iw_url, PROTO_CURRENT );
-                       if( isset( $row->iw_wikiid ) ) {
-                               $val['wikiid'] = $row->iw_wikiid;
+                       $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
+                       if( isset( $row['iw_wikiid'] ) ) {
+                               $val['wikiid'] = $row['iw_wikiid'];
                        }
-                       if( isset( $row->iw_api ) ) {
-                               $val['api'] = $row->iw_api;
+                       if( isset( $row['iw_api'] ) ) {
+                               $val['api'] = $row['iw_api'];
                        }
 
                        $data[] = $val;
@@ -476,13 +491,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function appendLanguages( $property ) {
                $params = $this->extractRequestParams();
-               $langCode = isset( $params['inlanguagecode '] ) ? $params['inlanguagecode '] : '';
-
-               if( $langCode ) {
-                       $langNames = Language::getTranslatedLanguageNames( $langCode );
-               } else {
-                       $langNames = Language::getLanguageNames();
-               }
+               $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
+               $langNames = Language::fetchLanguageNames( $langCode );
 
                $data = array();
 
@@ -583,7 +593,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        ),
                        'showalldb' => false,
                        'numberingroup' => false,
-                       'inlanguagecode ' => null,
+                       'inlanguagecode' => null,
                );
        }
 
@@ -613,7 +623,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',
                        'numberingroup' => 'Lists the number of users in user groups',
-                       'inlanguagecode ' => 'Language code for localised language names (best effort, use CLDR extension)',
+                       'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
                );
        }
 
@@ -636,7 +646,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
+               return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
        }
 
        public function getVersion() {