r51333 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51332‎ | r51333 | r51334 >
Date:09:49, 2 June 2009
Author:werdna
Status:ok (Comments)
Tags:
Comment:
Phase 1 in fixing up SiteConfiguration: Replace the hack of including InitialiseSettings.php with a generic system for loading full configuration data, involving a callback.
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialNoticeText.php (modified) (history)
  • /trunk/extensions/Configure/Configure.obj.php (modified) (history)
  • /trunk/extensions/SiteMatrix/SiteMatrix_body.php (modified) (history)
  • /trunk/phase3/includes/SiteConfiguration.php (modified) (history)
  • /trunk/phase3/includes/WikiMap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WikiMap.php
@@ -7,16 +7,9 @@
88 class WikiMap {
99 static function getWiki( $wikiID ) {
1010 global $wgConf, $IP;
11 - static $initialiseSettingsDone = false;
 11+
 12+ $wgConf->loadFullData();
1213
13 - // This is a damn dirty hack
14 - if ( !$initialiseSettingsDone ) {
15 - $initialiseSettingsDone = true;
16 - if( file_exists( "$IP/InitialiseSettings.php" ) ) {
17 - require_once "$IP/InitialiseSettings.php";
18 - }
19 - }
20 -
2114 list( $major, $minor ) = $wgConf->siteFromDB( $wikiID );
2215 if( isset( $major ) ) {
2316 $server = $wgConf->get( 'wgServer', $wikiID, $major,
Index: trunk/phase3/includes/SiteConfiguration.php
@@ -36,6 +36,14 @@
3737 * Array of domains that are local and can be handled by the same server
3838 */
3939 public $localVHosts = array();
 40+
 41+ /**
 42+ * Optional callback to load full configuration data.
 43+ */
 44+ public $fullLoadCallback = null;
 45+
 46+ /** Whether or not all data has been loaded */
 47+ public $fullLoadDone = false;
4048
4149 /**
4250 * A callback function that returns an array with the following keys (all
@@ -387,5 +395,12 @@
388396
389397 return $out;
390398 }
 399+
 400+ public function loadFullData() {
 401+ if ($this->fullLoadCallback && !$this->fullLoadDone) {
 402+ call_user_func( $this->fullLoadCallback );
 403+ $this->fullLoadDone = true;
 404+ }
 405+ }
391406 }
392 -}
 407+} // End of multiple inclusion guard
Index: trunk/extensions/Configure/Configure.obj.php
@@ -244,18 +244,12 @@
245245 * @return array
246246 */
247247 public function getDefaultsForWiki( $wiki ) {
248 - ## Hack for Wikimedia
249 - static $initialiseSettingsDone = false;
250 -
251248 wfProfileIn( __METHOD__ );
252249
253 - if ( !$initialiseSettingsDone ) {
254 - $initialiseSettingsDone = true;
255 - global $IP, $wgConf;
256 - if( file_exists( "$IP/InitialiseSettings.php" ) ) {
257 - require_once "$IP/InitialiseSettings.php";
258 - $this->initialise( false );
259 - }
 250+ global $wgConf;
 251+ if (!$wgConf->fullLoadDone) {
 252+ $wgConf->loadFullData();
 253+ $this->initialise( false );
260254 }
261255
262256 // Hmm, a better solution would be nice!
Index: trunk/extensions/CentralNotice/SpecialNoticeText.php
@@ -210,10 +210,7 @@
211211 private function projectName() {
212212 global $wgConf, $IP;
213213
214 - // This is a damn dirty hack
215 - if ( file_exists( "$IP/InitialiseSettings.php" ) ) {
216 - require_once "$IP/InitialiseSettings.php";
217 - }
 214+ $wgConf->loadFullData();
218215
219216 // Special cases for commons and meta who have no lang
220217 if ( $this->project == 'commons' )
Index: trunk/extensions/SiteMatrix/SiteMatrix_body.php
@@ -17,9 +17,7 @@
1818 global $wgSiteMatrixFile, $wgSiteMatrixSites;
1919 global $wgLocalDatabases, $IP, $wgConf;
2020
21 - if( file_exists( "$IP/InitialiseSettings.php" ) ) {
22 - require_once "$IP/InitialiseSettings.php";
23 - }
 21+ $wgConf->loadFullData();
2422
2523 if( file_exists( $wgSiteMatrixFile ) ){
2624 $this->langlist = array_map( 'trim', file( $wgSiteMatrixFile ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r51334Bump version and add CHANGELOG entry per r51333ialex10:08, 2 June 2009

Comments

#Comment by Werdna (talk | contribs)   15:34, 3 June 2009

Note: Needs configuration at MediaWiki.

#Comment by Tim Starling (talk | contribs)   04:16, 12 June 2009

Implemented on Wikimedia but also needs r51782. The Wikimedia configuration change was backwards compatible so there's no need for a simultaneous update.

Status & tagging log