From b7747368ba0c77346beb63c6ca96ca1d9bc58a3b Mon Sep 17 00:00:00 2001 From: catch Date: Sun, 22 Nov 2020 21:22:19 +0000 Subject: [PATCH] Issue #3098281 by greg.1.anderson, alexpott, heddn, Mile23, xjm, jungle, longwave: Ensure that 'composer update' evaluates dependencies using the correct PHP version --- composer.json | 5 ++++- composer.lock | 9 ++++++--- core/composer.json | 2 +- core/tests/Drupal/Tests/Composer/ComposerTest.php | 13 +++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 81e82632e68..c571b1ab710 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,10 @@ "prefer-stable": true, "config": { "preferred-install": "dist", - "autoloader-suffix": "Drupal9" + "autoloader-suffix": "Drupal9", + "platform": { + "php": "7.3.0" + } }, "extra": { "_readme": [ diff --git a/composer.lock b/composer.lock index 0cf513bd6ca..2d3defd071d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1387b767469672675eafc323b5e0b55a", + "content-hash": "825626fa3eb8a72e63e24d96adc6e33b", "packages": [ { "name": "asm89/stack-cors", @@ -528,7 +528,7 @@ "dist": { "type": "path", "url": "core", - "reference": "af5b9453adf15c6831b1f73e322f8c59da877f14" + "reference": "4659974dafc65cf2e9fbe00c8be0ccd0ef0aadba" }, "require": { "asm89/stack-cors": "^1.1", @@ -554,7 +554,7 @@ "laminas/laminas-feed": "^2.12", "masterminds/html5": "^2.1", "pear/archive_tar": "^1.4.9", - "php": ">=7.3", + "php": ">=7.3.0", "psr/log": "^1.0", "stack/builder": "^1.0", "symfony-cmf/routing": "^2.1", @@ -7693,5 +7693,8 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], + "platform-overrides": { + "php": "7.3.0" + }, "plugin-api-version": "2.0.0" } diff --git a/core/composer.json b/core/composer.json index 671a37e8d66..eea29f6acf3 100644 --- a/core/composer.json +++ b/core/composer.json @@ -17,7 +17,7 @@ "ext-SPL": "*", "ext-tokenizer": "*", "ext-xml": "*", - "php": ">=7.3", + "php": ">=7.3.0", "symfony/console": "^4.4", "symfony/dependency-injection": "^4.4", "symfony/event-dispatcher": "^4.4", diff --git a/core/tests/Drupal/Tests/Composer/ComposerTest.php b/core/tests/Drupal/Tests/Composer/ComposerTest.php index 2e1d1bdfaba..0eb4e227cdb 100644 --- a/core/tests/Drupal/Tests/Composer/ComposerTest.php +++ b/core/tests/Drupal/Tests/Composer/ComposerTest.php @@ -25,4 +25,17 @@ class ComposerTest extends UnitTestCase { } } + /** + * Ensure that the configured php version matches the minimum php version. + * + * Also ensure that the minimum php version in the root-level composer.json + * file exactly matches DRUPAL_MINIMUM_PHP. + */ + public function testEnsurePhpConfiguredVersion() { + $composer_json = json_decode(file_get_contents($this->root . '/composer.json'), TRUE); + $composer_core_json = json_decode(file_get_contents($this->root . '/core/composer.json'), TRUE); + $this->assertEquals(DRUPAL_MINIMUM_PHP, $composer_json['config']['platform']['php'], 'The DRUPAL_MINIMUM_PHP constant should always be exactly the same as the config.platform.php in the root composer.json.'); + $this->assertEquals($composer_core_json['require']['php'], '>=' . $composer_json['config']['platform']['php'], 'The config.platform.php configured version in the root composer.json file should always be exactly the same as the minimum php version configured in core/composer.json.'); + } + }