[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Execute mwcomposer just like composer
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/347222 ) Change subject: Execute mwcomposer just like composer .. Execute mwcomposer just like composer Previously mwcomposer selected the directory according to a configured wiki, but it introduces a chicken-and-egg problem when you want to upgrade: you create a new MediaWiki installation in another directory, change some wiki to this new version even if no Composer was run (and MediaWiki publicly complains on the Web), you run mwcomposer with this wiki, and then it works, and you can run update.php for each wiki. The trick could be to use a junk wiki, but this is now solved: now you prepare your new MediaWiki version, run mwcomposer just like you would have run composer, and then switch each wiki to this new version and run update.php for each wiki. By the way, wrote some documentation in docs/scripts.rst. Change-Id: I150e805bc32f7329784a501e75d7faf218e389e4 --- M docs/scripts.rst M src/MediaWikiFarmComposerScript.php M tests/phpunit/MediaWikiFarmComposerScriptTest.php 3 files changed, 57 insertions(+), 135 deletions(-) Approvals: Seb35: Looks good to me, approved jenkins-bot: Verified diff --git a/docs/scripts.rst b/docs/scripts.rst index 66e5ff9..5af70b0 100644 --- a/docs/scripts.rst +++ b/docs/scripts.rst @@ -4,6 +4,7 @@ Here are detailled the scripts provided with MediaWikiFarm: * :command:`mwscript` to execute a MediaWiki maintenance script in the context of a farm +* :command:`mwcomposer` to install Composer dependencies and give the opportunity to activate per-wiki a Composer-managed MediaWiki extension * :command:`validate-schema` to validate the main config file mwscript @@ -16,4 +17,17 @@ For your convenience, you can add it as an alias in your ~/.bashrc. The exact command is given when you run :command:`php mwscript.php --help`. With this alias, the command becomes :command:`mwscript update --wiki=mywiki.example.org`. +mwcomposer +== +:command:`mwcomposer` is very similar to :command:`composer` (and this one must be installed and is called) but creates a modified `vendor` directory (with multiple Composer autoloaders, a modified file `autoload.php`, and a added file `MediaWikiExtensions.php`) to activate per-wiki Composer-managed MediaWiki extensions. If you directly run :command:`composer` instead of :command:`mwcomposer` it will also "work", but all Composer-managed MediaWiki extensions will be activated on all wikis using this MediaWiki version (possibly some extensions have custom mechanisms to prevent themselves from being activated without specific parameters). + +To run this script, you must add in your `composer.json` or `composer.local.json` your Composer-managed MediaWiki extensions (and skins), then run this script in the MediaWiki directory just like you would have run Composer. + +Internally this script: +* run Composer with the original composer.json, so that if there are incompatibilities between some Composer-managed MediaWiki extensions, you are warned; +* run Composer one time per extension (so N Composer runs) by crafting the composer.json as if only the extension was the only one activated extension; +* run Composer without any extension; +* install MediaWiki extensions and skins in their standard directories; +* create a `vendor` directory with all Composer libraries, N Composer autoloader per MediaWiki extension, 1 Composer autoloader without any MediaWiki extension, a specific autoloader in place of `autoload.php`, and one `MediaWikiExtensions.php`. +Note that each Composer run is done in a temporary directory to avoid issues with the real MediaWiki directory. At runtime, the `autoload.php` file requests MediaWikiFarm to known what Composer-managed MediaWiki extensions are enabled and loads their autoloaders. The file `MediaWikiExtensions.php` is used by MediaWikiFarm during configuration compilation (to create the `LocalSettings.php` files) to know the dependency graph between Composer-managed MediaWiki extensions (given Composer computes and respects the dependencies, MediaWikiFarm should be aware of these dependencies). diff --git a/src/MediaWikiFarmComposerScript.php b/src/MediaWikiFarmComposerScript.php index 54da9bd..cb48d07 100644 --- a/src/MediaWikiFarmComposerScript.php +++ b/src/MediaWikiFarmComposerScript.php @@ -36,11 +36,11 @@ parent::__construct( $argc, $argv ); $this->shortUsage = " -Usage: php {$this->argv[0]} --wiki=hostname … +Usage: php {$this->argv[0]} … -Parameters: +You must be inside a Composer-managed MediaWiki directory. - - hostname: hostname of the wiki, e.g. \"mywiki.example.org\" +Parameters: regular Composer parameters "; $fullPath = realpath( $this->argv[0] ); @@ -50,7 +50,6 @@ | | Return codes: | 0 = success -| 1 =
[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Execute mwcomposer just like composer
Seb35 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/347222 ) Change subject: Execute mwcomposer just like composer .. Execute mwcomposer just like composer Previously mwcomposer selected the directory according to a configured wiki, but it introduces a chicken-and-egg problem when you want to upgrade: you create a new MediaWiki installation in another directory, change some wiki to this new version even if no Composer was run (and MediaWiki publicly complains on the Web), you run mwcomposer with this wiki, and then it works, and you can run update.php for each wiki. The trick could be to use a junk wiki, but this is now solved: now you prepare your new MediaWiki version, run mwcomposer just like you would have run composer, and then switch each wiki to this new version and run update.php for each wiki. By the way, wrote some documentation in docs/scripts.rst. Change-Id: I150e805bc32f7329784a501e75d7faf218e389e4 --- M docs/scripts.rst M src/MediaWikiFarmComposerScript.php M tests/phpunit/MediaWikiFarmComposerScriptTest.php 3 files changed, 57 insertions(+), 135 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/22/347222/1 diff --git a/docs/scripts.rst b/docs/scripts.rst index 66e5ff9..5af70b0 100644 --- a/docs/scripts.rst +++ b/docs/scripts.rst @@ -4,6 +4,7 @@ Here are detailled the scripts provided with MediaWikiFarm: * :command:`mwscript` to execute a MediaWiki maintenance script in the context of a farm +* :command:`mwcomposer` to install Composer dependencies and give the opportunity to activate per-wiki a Composer-managed MediaWiki extension * :command:`validate-schema` to validate the main config file mwscript @@ -16,4 +17,17 @@ For your convenience, you can add it as an alias in your ~/.bashrc. The exact command is given when you run :command:`php mwscript.php --help`. With this alias, the command becomes :command:`mwscript update --wiki=mywiki.example.org`. +mwcomposer +== +:command:`mwcomposer` is very similar to :command:`composer` (and this one must be installed and is called) but creates a modified `vendor` directory (with multiple Composer autoloaders, a modified file `autoload.php`, and a added file `MediaWikiExtensions.php`) to activate per-wiki Composer-managed MediaWiki extensions. If you directly run :command:`composer` instead of :command:`mwcomposer` it will also "work", but all Composer-managed MediaWiki extensions will be activated on all wikis using this MediaWiki version (possibly some extensions have custom mechanisms to prevent themselves from being activated without specific parameters). + +To run this script, you must add in your `composer.json` or `composer.local.json` your Composer-managed MediaWiki extensions (and skins), then run this script in the MediaWiki directory just like you would have run Composer. + +Internally this script: +* run Composer with the original composer.json, so that if there are incompatibilities between some Composer-managed MediaWiki extensions, you are warned; +* run Composer one time per extension (so N Composer runs) by crafting the composer.json as if only the extension was the only one activated extension; +* run Composer without any extension; +* install MediaWiki extensions and skins in their standard directories; +* create a `vendor` directory with all Composer libraries, N Composer autoloader per MediaWiki extension, 1 Composer autoloader without any MediaWiki extension, a specific autoloader in place of `autoload.php`, and one `MediaWikiExtensions.php`. +Note that each Composer run is done in a temporary directory to avoid issues with the real MediaWiki directory. At runtime, the `autoload.php` file requests MediaWikiFarm to known what Composer-managed MediaWiki extensions are enabled and loads their autoloaders. The file `MediaWikiExtensions.php` is used by MediaWikiFarm during configuration compilation (to create the `LocalSettings.php` files) to know the dependency graph between Composer-managed MediaWiki extensions (given Composer computes and respects the dependencies, MediaWikiFarm should be aware of these dependencies). diff --git a/src/MediaWikiFarmComposerScript.php b/src/MediaWikiFarmComposerScript.php index 54da9bd..cb48d07 100644 --- a/src/MediaWikiFarmComposerScript.php +++ b/src/MediaWikiFarmComposerScript.php @@ -36,11 +36,11 @@ parent::__construct( $argc, $argv ); $this->shortUsage = " -Usage: php {$this->argv[0]} --wiki=hostname … +Usage: php {$this->argv[0]} … -Parameters: +You must be inside a Composer-managed MediaWiki directory. - - hostname: hostname of the wiki, e.g. \"mywiki.example.org\" +Parameters: regular Composer parameters "; $fullPath = realpath( $this->argv[0] ); @@ -50,7 +50,6 @@ | | Return codes: | 0 =