r50064 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50063‎ | r50064 | r50065 >
Date:05:25, 30 April 2009
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Add lots more information to the siteinfo query. Based on the JS variable list.
Modified paths:
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -99,37 +99,38 @@
100100 }
101101
102102 protected function appendGeneralInfo( $property ) {
103 - global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText, $wgContLang;
104 - global $wgLanguageCode, $IP, $wgEnableWriteAPI, $wgLang, $wgLocaltimezone, $wgLocalTZoffset;
 103+ global $wgContLang;
 104+ global $wgLang;
105105
106106 $data = array();
107107 $mainPage = Title :: newFromText(wfMsgForContent('mainpage'));
108108 $data['mainpage'] = $mainPage->getPrefixedText();
109109 $data['base'] = $mainPage->getFullUrl();
110 - $data['sitename'] = $wgSitename;
111 - $data['generator'] = "MediaWiki $wgVersion";
 110+ $data['sitename'] = $GLOBALS['wgSitename'];
 111+ $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
112112
113 - $svn = SpecialVersion::getSvnRevision( $IP );
 113+ $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
114114 if( $svn )
115115 $data['rev'] = $svn;
116116
117 - $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future
 117+ // 'case-insensitive' option is reserved for future
 118+ $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
118119
119 - if( isset( $wgRightsCode ) )
120 - $data['rightscode'] = $wgRightsCode;
121 - $data['rights'] = $wgRightsText;
122 - $data['lang'] = $wgLanguageCode;
 120+ if( isset( $GLOBALS['wgRightsCode'] ) )
 121+ $data['rightscode'] = $GLOBALS['wgRightsCode'];
 122+ $data['rights'] = $GLOBALS['wgRightsText'];
 123+ $data['lang'] = $GLOBALS['wgLanguageCode'];
123124 if( $wgContLang->isRTL() )
124125 $data['rtl'] = '';
125126 $data['fallback8bitEncoding'] = $wgLang->fallback8bitEncoding();
126127
127128 if( wfReadOnly() )
128129 $data['readonly'] = '';
129 - if( $wgEnableWriteAPI )
 130+ if( $GLOBALS['wgEnableWriteAPI'] )
130131 $data['writeapi'] = '';
131132
132 - $tz = $wgLocaltimezone;
133 - $offset = $wgLocalTZoffset;
 133+ $tz = $GLOBALS['wgLocaltimezone'];
 134+ $offset = $GLOBALS['wgLocalTZoffset'];
134135 if( is_null( $tz ) ) {
135136 $tz = 'UTC';
136137 $offset = 0;
@@ -138,6 +139,12 @@
139140 }
140141 $data['timezone'] = $tz;
141142 $data['timeoffset'] = intval($offset);
 143+ $data['articlepath'] = $GLOBALS['wgArticlePath'];
 144+ $data['scriptpath'] = $GLOBALS['wgScriptPath'];
 145+ $data['script'] = $GLOBALS['wgScript'];
 146+ $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
 147+ $data['server'] = $GLOBALS['wgServer'];
 148+ $data['wikiid'] = wfWikiID();
142149
143150 return $this->getResult()->addValue( 'query', $property, $data );
144151 }
@@ -441,4 +448,4 @@
442449 public function getVersion() {
443450 return __CLASS__ . ': $Id$';
444451 }
445 -}
\ No newline at end of file
 452+}

Comments

#Comment by Brion VIBBER (talk | contribs)   00:20, 6 May 2009

+ $data['lang'] = $GLOBALS['wgLanguageCode'];

^ Shouldn't this be wgContLanguageCode? It's not new though, so no rush. :)

#Comment by Tim Starling (talk | contribs)   07:13, 19 May 2009

They are the same, since StubObject was invented. See Setup.php:

  1. These are now the same, always
  2. To determine the user language, use $wgLang->getCode()

$wgContLanguageCode = $wgLanguageCode;

I thought I would use the shorter one.

Status & tagging log