From 1b442fd3d6642914bd83e34c62c5368e98a13903 Mon Sep 17 00:00:00 2001 From: Jure Kajzer Date: Wed, 1 Jun 2011 13:43:38 +0000 Subject: [PATCH] * trying to create a way to update/install extension already included in the LocalSettings.php * wgHooks and wgAutoloadClasses are initialized so they can be appended within extension inits --- includes/installer/DatabaseUpdater.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 00d2d69d3e..bc55ccea6f 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -67,6 +67,7 @@ abstract class DatabaseUpdater { } $this->maintenance->setDB( $db ); $this->initOldGlobals(); + $this->initIncludedExtensions(); wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) ); } @@ -88,6 +89,28 @@ abstract class DatabaseUpdater { $wgExtModifiedFields = array(); // table, index, dir } + /** + * Try to include extensions from LocalSettings so their LocalExtensionSchemaChanges hooks can be run + */ + private function initIncludedExtensions() { + global $IP, $wgHooks, $wgAutoloadClasses; + $ls = file_get_contents( "$IP/LocalSettings.php" ); + if ( $ls === false ) return; + $matches = array(); + preg_match_all( '/[[:blank:]]*(?:require|include){1}(?:_once)?[[:blank:]]*\([[:blank:]]*"\$IP\/extensions\/([^\/].*)\/\1\.php"[[:blank:]]*\);[[:blank:]]*/i', + $ls, $matches, PREG_SET_ORDER ); + unset( $ls ); + + if ( !isset( $wgHooks ) ) + $wgHooks = array(); + if ( !isset( $wgAutoloadClasses ) ) + $wgAutoloadClasses = array(); + + foreach ( $matches as $match ) { + include_once ( "$IP/extensions/{$match[1]}/{$match[1]}.php" ); + } + } + /** * @throws MWException * @param DatabaseBase $db -- 2.20.1