From a6f172ef3cced06f808e22c425bb272e4f5178c7 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 10 Jan 2017 10:47:08 -0800 Subject: [PATCH] registration: Don't initialize MWServices super early Previously, MediaWikiServices would be initialized on the first wfLoadExtension() call, which is super early and before it should be. There's actually no reason we need to create the BagOStuff object in the constructor, so let's defer it to loadFromQueue(). It now gets called from the top of Setup.php, which is still a little early, but better than before. Bug: T154960 Change-Id: I3feef3b974ba1ba3afec0d453e1899cd476e72fb --- includes/registration/ExtensionRegistry.php | 26 +++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index c5b21500f5..344dd8f5c0 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -40,11 +40,6 @@ class ExtensionRegistry { */ const MERGE_STRATEGY = '_merge_strategy'; - /** - * @var BagOStuff - */ - protected $cache; - /** * Array of loaded things, keyed by name, values are credits information * @@ -90,16 +85,6 @@ class ExtensionRegistry { return self::$instance; } - public function __construct() { - // We use a try/catch because we don't want to fail here - // if $wgObjectCaches is not configured properly for APC setup - try { - $this->cache = MediaWikiServices::getInstance()->getLocalServerObjectCache(); - } catch ( MWException $e ) { - $this->cache = new EmptyBagOStuff(); - } - } - /** * @param string $path Absolute path to the JSON file */ @@ -144,12 +129,19 @@ class ExtensionRegistry { 'mediawiki' => $wgVersion ]; + // We use a try/catch because we don't want to fail here + // if $wgObjectCaches is not configured properly for APC setup + try { + $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache(); + } catch ( MWException $e ) { + $cache = new EmptyBagOStuff(); + } // See if this queue is in APC $key = wfMemcKey( 'registration', md5( json_encode( $this->queued + $versions ) ) ); - $data = $this->cache->get( $key ); + $data = $cache->get( $key ); if ( $data ) { $this->exportExtractedData( $data ); } else { @@ -159,7 +151,7 @@ class ExtensionRegistry { // did that, but it should be cached $data['globals']['wgAutoloadClasses'] += $data['autoload']; unset( $data['autoload'] ); - $this->cache->set( $key, $data, 60 * 60 * 24 ); + $cache->set( $key, $data, 60 * 60 * 24 ); } $this->queued = []; } -- 2.20.1