jenkins-bot has submitted this change and it was merged. Change subject: ExtensionManager: Use autoloader #2 ......................................................................
ExtensionManager: Use autoloader #2 Rewrite of ExtensionManager to use autoloader. PatchSet 2: Removed old double indentation. Change-Id: Idbad7dc69086ef507aebaa780e1b860a8fa2a466 --- M includes/ExtensionManager.class.php 1 file changed, 22 insertions(+), 22 deletions(-) Approvals: Mglaser: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/ExtensionManager.class.php b/includes/ExtensionManager.class.php index d9c6935..8c86a69 100644 --- a/includes/ExtensionManager.class.php +++ b/includes/ExtensionManager.class.php @@ -18,7 +18,6 @@ protected static $prRunningExtensions = array(); protected static $aContexts = array(); protected static $aActiveContexts = array(); - protected static $aIncludedClasses = array(); public static function addContext( $sKey ) { wfProfileIn( 'Performance: ' . __METHOD__ ); @@ -85,29 +84,30 @@ $path = "$IP/extensions/BlueSpiceExtensions"; foreach ( self::$prRegisteredExtensions as $extension => $attributes ) { - /* -- reverted, this doesn't work - //if possible, load by autoloader - if( class_exists( 'Bs' . $extension ) || class_exists( $extension ) ) { - continue; - } - */ - if ( $attributes['baseDir'] != 'ext' ) { - require( $attributes['baseDir'] . DS . $extension . '.class.php' ); - } else { - require( $path . DS . $extension . DS . $extension . '.class.php' ); - } - self::$aIncludedClasses[] = $extension; - } + $sClassName = $extension; - foreach ( self::$aIncludedClasses as $key => $value ) { - if ( class_exists( 'Bs' . $value, false ) ) { - $class = 'Bs' . $value; - } else { - $class = $value; + //Check if autoloader knows class with extension name and if it + //is of type 'BsExtensionMW' + if ( !is_subclass_of( $sClassName, 'BsExtensionMW' ) ) { + //Check if autoloader knows a prefixed class name + $sClassName = 'Bs'.$sClassName; + if ( !is_subclass_of( $sClassName, 'BsExtensionMW' ) ) { + if ( $attributes['baseDir'] != 'ext' ) { + require( $attributes['baseDir'] . DS . $extension . '.class.php' ); + } else { + require( $path . DS . $extension . DS . $extension . '.class.php' ); + } + //Now we only need to check whether to use the prefixed or + //the unprefixed extension name as class name for instantiation + if( !class_exists( $sClassName, false ) ) { + $sClassName = $extension; + } + } } - self::$prRunningExtensions[$value] = new $class(); - self::$prRunningExtensions[$value]->setCore( $oCore ); - self::$prRunningExtensions[$value]->setup(); + + self::$prRunningExtensions[$extension] = new $sClassName(); + self::$prRunningExtensions[$extension]->setCore( $oCore ); + self::$prRunningExtensions[$extension]->setup(); } wfProfileOut( 'Performance: ' . __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/276407 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Idbad7dc69086ef507aebaa780e1b860a8fa2a466 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation Gerrit-Branch: master Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz> Gerrit-Reviewer: Dvogel hallowelt <daniel.vo...@hallowelt.com> Gerrit-Reviewer: Ljonka <l.verhovs...@gmail.com> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Pwirth <wi...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits