r44875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44874‎ | r44875 | r44876 >
Date:18:09, 21 December 2008
Author:ialex
Status:ok
Tags:
Comment:
delay handler initialisation
Modified paths:
  • /trunk/extensions/Configure/Configure.obj.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Configure/Configure.obj.php
@@ -7,7 +7,7 @@
88 * @ingroup Extensions
99 */
1010 class WebConfiguration extends SiteConfiguration {
11 - protected $mHandler; // Configuration handler
 11+ protected $mHandler = null; // Configuration handler
1212 protected $mWiki; // Wiki name
1313 protected $mConf = array(); // Our array of settings
1414 protected $mOldSettings = null; // Old settings (before applying our overrides)
@@ -20,9 +20,6 @@
2121 * files
2222 */
2323 public function __construct( $wiki = 'default' ) {
24 - global $wgConfigureHandler;
25 - $class = 'ConfigureHandler' . ucfirst( $wgConfigureHandler );
26 - $this->mHandler = new $class();
2724 $this->mWiki = $wiki;
2825 }
2926
@@ -38,7 +35,7 @@
3936 if ( defined( 'EXT_CONFIGURE_NO_EXTRACT' ) )
4037 return;
4138
42 - $this->mConf = $this->mHandler->getCurrent( $useCache );
 39+ $this->mConf = $this->getHandler()->getCurrent( $useCache );
4340
4441 # Restore first version of $this->settings if called a second time so
4542 # that it doesn't duplicate arrays
@@ -155,6 +152,21 @@
156153 }
157154
158155 /**
 156+ * Get the configuration handler
 157+ * Used for lasy-loading
 158+ *
 159+ * @return ConfigureHandler object
 160+ */
 161+ public function getHandler() {
 162+ if ( !is_object( $this->mHandler ) ) {
 163+ global $wgConfigureHandler;
 164+ $class = 'ConfigureHandler' . ucfirst( $wgConfigureHandler );
 165+ $this->mHandler = new $class();
 166+ }
 167+ return $this->mHandler;
 168+ }
 169+
 170+ /**
159171 * Return the old configuration from $ts timestamp
160172 * Does *not* return site specific settings but *all* settings
161173 *
@@ -164,7 +176,7 @@
165177 public function getOldSettings( $ts ) {
166178 if ( $ts == 'default' )
167179 return array( 'default' => $this->getDefaults() );
168 - return $this->mHandler->getOldSettings( $ts );
 180+ return $this->getHandler()->getOldSettings( $ts );
169181 }
170182
171183 /**
@@ -174,7 +186,7 @@
175187 * @return array
176188 */
177189 public function getWikisInVersion( $ts ) {
178 - return $this->mHandler->getWikisInVersion( $ts );
 190+ return $this->getHandler()->getWikisInVersion( $ts );
179191 }
180192
181193 /** Recursive doohicky for normalising variables so we can compare them. */
@@ -196,7 +208,7 @@
197209 * @return Pager
198210 */
199211 public function getPager() {
200 - return $this->mHandler->getPager();
 212+ return $this->getHandler()->getPager();
201213 }
202214
203215 /**
@@ -284,7 +296,7 @@
285297 $this->mConf[$wiki] = $settings;
286298 }
287299
288 - return $this->mHandler->saveNewSettings( $this->mConf, $wiki, false, $reason );
 300+ return $this->getHandler()->saveNewSettings( $this->mConf, $wiki, false, $reason );
289301 }
290302
291303 /**
@@ -294,7 +306,7 @@
295307 * @return array of timestamps
296308 */
297309 public function listArchiveVersions( $options = array() ) {
298 - return $this->mHandler->listArchiveVersions( $options );
 310+ return $this->getHandler()->listArchiveVersions( $options );
299311 }
300312
301313 /**
@@ -305,14 +317,14 @@
306318 * @return Array of versions
307319 */
308320 public function getArchiveVersions( $options = array() ) {
309 - return $this->mHandler->getArchiveVersions( $options );
 321+ return $this->getHandler()->getArchiveVersions( $options );
310322 }
311323
312324 /**
313325 * Do some checks
314326 */
315327 public function doChecks() {
316 - return $this->mHandler->doChecks();
 328+ return $this->getHandler()->doChecks();
317329 }
318330
319331 /**
@@ -320,7 +332,7 @@
321333 * @return array
322334 */
323335 public function getUneditableSettings() {
324 - return $this->mHandler->getUneditableSettings();
 336+ return $this->getHandler()->getUneditableSettings();
325337 }
326338
327339 /**
@@ -330,7 +342,7 @@
331343 * @return bool
332344 */
333345 public function versionExists( $ts ) {
334 - return $this->mHandler->versionExists( $ts );
 346+ return $this->getHandler()->versionExists( $ts );
335347 }
336348
337349 /**
@@ -343,14 +355,6 @@
344356 }
345357
346358 /**
347 - * Get the configuration handler
348 - * @return ConfigurationHandler
349 - */
350 - public function getHandler() {
351 - return $this->mHandler;
352 - }
353 -
354 - /**
355359 * Merge array settings
356360 * TODO: document!
357361 * @return Array

Status & tagging log