[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Refactoring: extraction of configuration compilation
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/355633 ) Change subject: Refactoring: extraction of configuration compilation .. Refactoring: extraction of configuration compilation The main class MediaWikiFarm had a lot of responsabilities, one of those was to compile configuration for a specific wiki. This commits splits out this configuration compilation into a dedicated class. In number of lines, the main class MediaWikiFarm drops from 2030 to 1427. This is a first step to more refactoring to create smaller functions and possibly multiple classes, in order to facilitate long-term maintenance and improve understanding. Possibly the 'existence' feature inside the main class will be also splitted out into a dedicated class, which would become sort of a (dependency injection) container. BTW, updated PHPCS rule exceptions for PHPCS-MediaWiki 0.8. Change-Id: I54d4d2739215f9cc4f59fb2671d2cd7e797d16f9 --- M docs/config/farms.php M extension.json M phpcs.xml M src/MediaWikiFarm.php M src/MediaWikiFarmComposerScript.php A src/MediaWikiFarmConfiguration.php M tests/perfs/MediaWikiFarmTestPerfs.php M tests/phpunit/ConfigurationTest.php M tests/phpunit/ConstructionTest.php M tests/phpunit/InstallationIndependantTest.php M tests/phpunit/LoadingTest.php M tests/phpunit/MediaWikiFarmComposerScriptTest.php M tests/phpunit/MediaWikiFarmScriptTest.php M tests/phpunit/MediaWikiFarmTestCase.php M tests/phpunit/MultiversionInstallationTest.php 15 files changed, 1,055 insertions(+), 788 deletions(-) Approvals: Seb35: Looks good to me, approved jenkins-bot: Verified diff --git a/docs/config/farms.php b/docs/config/farms.php index 317d726..cc285e4 100644 --- a/docs/config/farms.php +++ b/docs/config/farms.php @@ -16,7 +16,9 @@ ), ); +// @codingStandardsIgnoreStart MediaWiki.Commenting.IllegalSingleLineComment.MissingCommentEndding /* + return array( # Configuration similar to the Wikimedia farm @@ -94,4 +96,5 @@ 'redirect' => '$client-$wiki.example.com', ), ); + */ diff --git a/extension.json b/extension.json index 0526ebb..5bd8da9 100644 --- a/extension.json +++ b/extension.json @@ -29,6 +29,7 @@ }, "AutoloadClasses": { "MediaWikiFarm": "src/MediaWikiFarm.php", + "MediaWikiFarmConfiguration": "src/MediaWikiFarmConfiguration.php", "AbstractMediaWikiFarmScript": "src/AbstractMediaWikiFarmScript.php", "MediaWikiFarmScript": "src/MediaWikiFarmScript.php", "MediaWikiFarmHooks": "src/Hooks.php", diff --git a/phpcs.xml b/phpcs.xml index 9a172ae..f89e22f 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -16,6 +16,18 @@ + + + + + + + + + + + + diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 6705369..f269008 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -11,6 +11,10 @@ * PHP 5.2+, so please do not use "new" syntaxes (namespaces, arrays with [], etc.). */ +// @codeCoverageIgnoreStart +require_once dirname( __FILE__ ) . '/MediaWikiFarmConfiguration.php'; +// @codeCoverageIgnoreEnd + /** * Exception triggered when a configuration file is “wrong” or other internal issue. * @@ -74,19 +78,8 @@ '$CODE' => '', ); - /** @var array Environment. */ - protected $environment = array( - 'ExtensionRegistry' => null, - ); - - /** @var array Configuration parameters for this wiki. */ - protected $configuration = array( - 'settings' => array(), - 'arrays' => array(), - 'extensions' => array(), - 'execFiles' => array(), - 'composer' => array(), - ); + /** @var MediaWikiFarmConfiguration|null Object containing the configuration of the current (single) wiki. */ + protected $configuration = null; /** @var array Logs. */ public $log = array(); @@ -110,6 +103,32 @@ return $this->state[$key]; } return null; + } + + /** +* Get farm this farm code directory. +* +* @api +* @mediawikifarm-const +* @mediawikifarm-idempotent +* +* @return string|null Farm code directory. +*/ + function getFarmDir() { + return $this->farmDir; + } + + /** +* Get config directory. +* +* @api +* @mediawikifarm-const +* @mediawikifarm-idempotent +* +* @return string|null Config directory. +*/ + function
[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Refactoring: extraction of configuration compilation
Seb35 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/355633 ) Change subject: Refactoring: extraction of configuration compilation .. Refactoring: extraction of configuration compilation The main class MediaWikiFarm had a lot of responsabilities, one of those was to compile configuration for a specific wiki. This commits splits out this configuration compilation into a dedicated class. In number of lines, the main class MediaWikiFarm drops from 2030 to 1427. This is a first step to more refactoring to create smaller functions and possibly multiple classes, in order to facilitate long-term maintenance and improve understanding. Possibly the 'existence' feature inside the main class will be also splitted out into a dedicated class, which would become sort of a (dependency injection) container. Change-Id: I54d4d2739215f9cc4f59fb2671d2cd7e797d16f9 --- M extension.json M src/MediaWikiFarm.php M src/MediaWikiFarmComposerScript.php A src/MediaWikiFarmConfiguration.php M tests/perfs/MediaWikiFarmTestPerfs.php M tests/phpunit/ConfigurationTest.php M tests/phpunit/ConstructionTest.php M tests/phpunit/InstallationIndependantTest.php M tests/phpunit/LoadingTest.php M tests/phpunit/MediaWikiFarmComposerScriptTest.php M tests/phpunit/MediaWikiFarmScriptTest.php 11 files changed, 1,038 insertions(+), 784 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/33/355633/1 diff --git a/extension.json b/extension.json index 0526ebb..5bd8da9 100644 --- a/extension.json +++ b/extension.json @@ -29,6 +29,7 @@ }, "AutoloadClasses": { "MediaWikiFarm": "src/MediaWikiFarm.php", + "MediaWikiFarmConfiguration": "src/MediaWikiFarmConfiguration.php", "AbstractMediaWikiFarmScript": "src/AbstractMediaWikiFarmScript.php", "MediaWikiFarmScript": "src/MediaWikiFarmScript.php", "MediaWikiFarmHooks": "src/Hooks.php", diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 6705369..f269008 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -11,6 +11,10 @@ * PHP 5.2+, so please do not use "new" syntaxes (namespaces, arrays with [], etc.). */ +// @codeCoverageIgnoreStart +require_once dirname( __FILE__ ) . '/MediaWikiFarmConfiguration.php'; +// @codeCoverageIgnoreEnd + /** * Exception triggered when a configuration file is “wrong” or other internal issue. * @@ -74,19 +78,8 @@ '$CODE' => '', ); - /** @var array Environment. */ - protected $environment = array( - 'ExtensionRegistry' => null, - ); - - /** @var array Configuration parameters for this wiki. */ - protected $configuration = array( - 'settings' => array(), - 'arrays' => array(), - 'extensions' => array(), - 'execFiles' => array(), - 'composer' => array(), - ); + /** @var MediaWikiFarmConfiguration|null Object containing the configuration of the current (single) wiki. */ + protected $configuration = null; /** @var array Logs. */ public $log = array(); @@ -110,6 +103,32 @@ return $this->state[$key]; } return null; + } + + /** +* Get farm this farm code directory. +* +* @api +* @mediawikifarm-const +* @mediawikifarm-idempotent +* +* @return string|null Farm code directory. +*/ + function getFarmDir() { + return $this->farmDir; + } + + /** +* Get config directory. +* +* @api +* @mediawikifarm-const +* @mediawikifarm-idempotent +* +* @return string|null Config directory. +*/ + function getConfigDir() { + return $this->configDir; } /** @@ -198,23 +217,19 @@ * @api * @mediawikifarm-const * -* @param string|null $key Key of the wanted section or null for the whole array. -* @param string|null $key2 Subkey (specific to each entry) or null for the whole entry. -* @return array MediaWiki configuration, either entire, either a part depending on the parameter. +* @param string|false|null $key Key of the wanted section or false for the whole array or null for the object configuration. +* @param string|false $key2 Subkey (specific to each entry) or false for the whole entry. +* @return array|MediaWikiFarmConfiguration MediaWiki configuration, either entire, either a part depending on the parameter, or the configuration object. */ - function getConfiguration( $key = null, $key2 = null ) { - if( $key !== null ) { - if( array_key_exists( $key,