aboutsummaryrefslogtreecommitdiffstats
path: root/includes/composer/VersionChecker.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2024-01-31 10:07:49 +0300
committerTim Starling <tstarling@wikimedia.org>2024-01-31 10:07:49 +0300
commit2ed8bb915da6cebd58badb26a6baa0bbf44f64bc (patch)
treecf4da1818b65b094825cf09cc9fd6acd64a84a70 /includes/composer/VersionChecker.php
parenta0e1796f37ed201dbae656ef21e1ec93fb5121b4 (diff)
downloadmediawikicore-2ed8bb915da6cebd58badb26a6baa0bbf44f64bc.tar.gz
mediawikicore-2ed8bb915da6cebd58badb26a6baa0bbf44f64bc.zip
composer: Allow unreleased composer versions
If you try to do `composer update` using a git checkout of a Composer branch, it fails because "@package_version@" is less than 2.0.0. So in that case, use Composer::getVersion() which falls back to Composer::SOURCE_VERSION. The method doesn't exist on very old versions of Composer, so we can't use it unconditionally. Change-Id: I53ea01c2f992499a25ba851bd8ed3593c9a13711
Diffstat (limited to 'includes/composer/VersionChecker.php')
-rw-r--r--includes/composer/VersionChecker.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/includes/composer/VersionChecker.php b/includes/composer/VersionChecker.php
index e4f1bfbdbfe2..f41f4d547187 100644
--- a/includes/composer/VersionChecker.php
+++ b/includes/composer/VersionChecker.php
@@ -29,7 +29,13 @@ use RuntimeException;
*/
class VersionChecker {
public static function onEvent() {
- if ( version_compare( Composer::VERSION, '2.0.0', '<' ) ) {
+ $version = Composer::VERSION;
+ if ( $version === '@package_version@' ) {
+ // In Composer 1.9+, unreleased git branches have this value in Composer::VERSION,
+ // and Composer::getVersion() was introduced to work around this.
+ $version = Composer::getVersion();
+ }
+ if ( version_compare( $version, '2.0.0', '<' ) ) {
throw new RuntimeException(
"MediaWiki requires Composer version 2 or later; version 1"
. " has been considered end of life since October 2020!"