From af184614e55ee88d815e62bf53375753501b0807 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Tue, 2 Jun 2009 09:49:31 +0000 Subject: [PATCH] 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. --- includes/SiteConfiguration.php | 17 ++++++++++++++++- includes/WikiMap.php | 11 ++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 2ed2813956..a6a50a25f7 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -36,6 +36,14 @@ class SiteConfiguration { * Array of domains that are local and can be handled by the same server */ public $localVHosts = array(); + + /** + * Optional callback to load full configuration data. + */ + public $fullLoadCallback = null; + + /** Whether or not all data has been loaded */ + public $fullLoadDone = false; /** * A callback function that returns an array with the following keys (all @@ -387,5 +395,12 @@ class SiteConfiguration { return $out; } + + public function loadFullData() { + if ($this->fullLoadCallback && !$this->fullLoadDone) { + call_user_func( $this->fullLoadCallback ); + $this->fullLoadDone = true; + } + } } -} +} // End of multiple inclusion guard diff --git a/includes/WikiMap.php b/includes/WikiMap.php index db9d17da31..6b6147be69 100644 --- a/includes/WikiMap.php +++ b/includes/WikiMap.php @@ -7,15 +7,8 @@ class WikiMap { static function getWiki( $wikiID ) { global $wgConf, $IP; - static $initialiseSettingsDone = false; - - // This is a damn dirty hack - if ( !$initialiseSettingsDone ) { - $initialiseSettingsDone = true; - if( file_exists( "$IP/InitialiseSettings.php" ) ) { - require_once "$IP/InitialiseSettings.php"; - } - } + + $wgConf->loadFullData(); list( $major, $minor ) = $wgConf->siteFromDB( $wikiID ); if( isset( $major ) ) { -- 2.20.1