Phase 1 in fixing up SiteConfiguration: Replace the hack of including InitialiseSetti...
authorAndrew Garrett <werdna@users.mediawiki.org>
Tue, 2 Jun 2009 09:49:31 +0000 (09:49 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Tue, 2 Jun 2009 09:49:31 +0000 (09:49 +0000)
includes/SiteConfiguration.php
includes/WikiMap.php

index 2ed2813..a6a50a2 100644 (file)
@@ -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
index db9d17d..6b6147b 100644 (file)
@@ -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 ) ) {