From cf2678e24d761d9887469e021a552b7f84862bd1 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 6 May 2015 13:48:07 +0100 Subject: [PATCH] Allow override of extension directory Also sets default paths immediately (not in Setup.php) so they are available before extensions register. Bug: T98319 Change-Id: I41a8aec7a3e9c576ec7344abf51f8106248ade4b --- RELEASE-NOTES-1.25 | 2 ++ includes/DefaultSettings.php | 9 ++++++++- includes/GlobalFunctions.php | 24 ++++++++++++------------ includes/Setup.php | 3 --- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index d844be211b..e91a02e124 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -47,6 +47,8 @@ production. be installed and running for any such queues to work. * $wgAutopromoteOnce no longer supports the 'view' event. For keeping some compatibility, any 'view' event triggers will still trigger on 'edit'. +* $wgExtensionDirectory was added for when your extensions directory is somewhere + other than $IP/extensions (as $wgStyleDirectory does with the skins directory). === New features in 1.25 === * (T64861) Updated plural rules to CLDR 26. Includes incompatible changes diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 51e807c46c..2b3bce56e8 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -220,12 +220,19 @@ $wgLocalStylePath = false; */ $wgExtensionAssetsPath = false; +/** + * Filesystem extensions directory. + * Defaults to "{$IP}/extensions". + * @since 1.25 + */ +$wgExtensionDirectory = "{$IP}/extensions"; + /** * Filesystem stylesheets directory. * Defaults to "{$IP}/skins". * @since 1.3 */ -$wgStyleDirectory = false; +$wgStyleDirectory = "{$IP}/skins"; /** * The URL path for primary article page views. This path should contain $1, diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 23a8bbbeba..6eaeb25afd 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -170,13 +170,13 @@ if ( !function_exists( 'hash_equals' ) ) { * This queues an extension to be loaded through * the ExtensionRegistry system. * - * @param string $name Name of the extension to load + * @param string $ext Name of the extension to load * @param string|null $path Absolute path of where to find the extension.json file */ -function wfLoadExtension( $name, $path = null ) { +function wfLoadExtension( $ext, $path = null ) { if ( !$path ) { - global $IP; - $path = "$IP/extensions/$name/extension.json"; + global $wgExtensionDirectory; + $path = "$wgExtensionDirectory/$ext/extension.json"; } ExtensionRegistry::getInstance()->queue( $path ); } @@ -194,10 +194,10 @@ function wfLoadExtension( $name, $path = null ) { * @param string[] $exts Array of extension names to load */ function wfLoadExtensions( array $exts ) { - global $IP; + global $wgExtensionDirectory; $registry = ExtensionRegistry::getInstance(); foreach ( $exts as $ext ) { - $registry->queue( "$IP/extensions/$ext/extension.json" ); + $registry->queue( "$wgExtensionDirectory/$ext/extension.json" ); } } @@ -205,13 +205,13 @@ function wfLoadExtensions( array $exts ) { * Load a skin * * @see wfLoadExtension - * @param string $name Name of the extension to load + * @param string $skin Name of the extension to load * @param string|null $path Absolute path of where to find the skin.json file */ -function wfLoadSkin( $name, $path = null ) { +function wfLoadSkin( $skin, $path = null ) { if ( !$path ) { - global $IP; - $path = "$IP/skins/$name/skin.json"; + global $wgStyleDirectory; + $path = "$wgStyleDirectory/$skin/skin.json"; } ExtensionRegistry::getInstance()->queue( $path ); } @@ -223,10 +223,10 @@ function wfLoadSkin( $name, $path = null ) { * @param string[] $skins Array of extension names to load */ function wfLoadSkins( array $skins ) { - global $IP; + global $wgStyleDirectory; $registry = ExtensionRegistry::getInstance(); foreach ( $skins as $skin ) { - $registry->queue( "$IP/skins/$skin/skin.json" ); + $registry->queue( "$wgStyleDirectory/$skin/skin.json" ); } } diff --git a/includes/Setup.php b/includes/Setup.php index 9a911564f9..7a333284c2 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -74,9 +74,6 @@ if ( $wgStylePath === false ) { if ( $wgLocalStylePath === false ) { $wgLocalStylePath = "$wgScriptPath/skins"; } -if ( $wgStyleDirectory === false ) { - $wgStyleDirectory = "$IP/skins"; -} if ( $wgExtensionAssetsPath === false ) { $wgExtensionAssetsPath = "$wgScriptPath/extensions"; } -- 2.20.1