Merge "Added assertArrayEquals method to MediaWikiTestCase to avoid duplicating asort...
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 9c1bef7..511cbe4 100644 (file)
@@ -93,6 +93,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'showhooks':
                                        $fit = $this->appendSubscribedHooks( $p );
                                        break;
+                               case 'variables':
+                                       $fit = $this->appendVariables( $p );
+                                       break;
                                default:
                                        ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
                        }
@@ -121,9 +124,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 +150,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'] = '';
                }
@@ -207,7 +224,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                $data[$ns]['content'] = '';
                        }
 
-                       if ( MWNamespace::isNonincludableNamespace( $ns ) ) {
+                       if ( MWNamespace::isNonincludable( $ns ) ) {
                                $data[$ns]['nonincludable'] = '';
                        }
                }
@@ -240,8 +257,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        protected function appendSpecialPageAliases( $property ) {
                global $wgContLang;
                $data = array();
-               foreach ( $wgContLang->getSpecialPageAliases() as $specialpage => $aliases ) {
-                       $arr = array( 'realname' => $specialpage, 'aliases' => $aliases );
+               $aliases = $wgContLang->getSpecialPageAliases();
+               foreach ( SpecialPageFactory::getList() as $specialpage => $stuff ) {
+                       $arr = array( 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] );
                        $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
                        $data[] = $arr;
                }
@@ -518,6 +536,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return $this->getResult()->addValue( 'query', $property, $hooks );
        }
 
+       public function appendVariables( $property ) {
+               $variables = MagicWord::getVariableIDs();
+               $this->getResult()->setIndexedTagName( $variables, 'v' );
+               return $this->getResult()->addValue( 'query', $property, $variables );
+       }
+
        private function formatParserTags( $item ) {
                return "<{$item}>";
        }
@@ -569,6 +593,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'extensiontags',
                                        'functionhooks',
                                        'showhooks',
+                                       'variables',
                                )
                        ),
                        'filteriw' => array(
@@ -604,7 +629,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' skins                 - Returns a list of all enabled skins',
                                ' extensiontags         - Returns a list of parser extension tags',
                                ' functionhooks         - Returns a list of parser function hooks',
-                               ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)'
+                               ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)',
+                               ' variables             - Returns a list of variable IDs',
                        ),
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',