From 68f86be7269c7d6286fe837aa65cd713520d3e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 20 May 2021 09:42:21 +0200 Subject: [PATCH 1/4] Allow Symfony 6.0 (#9896) --- composer.json | 10 +++++----- composer.lock | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 0ee8df488..3434fc1f5 100644 --- a/composer.json +++ b/composer.json @@ -32,14 +32,14 @@ "psr/log": "^1.0", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.0", - "symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0", - "symfony/filesystem": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0", - "symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0", - "symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0", + "symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/filesystem": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", "react/promise": "^1.2 || ^2.7" }, "require-dev": { - "symfony/phpunit-bridge": "^4.2 || ^5.0", + "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0", "phpspec/prophecy": "^1.10" }, "suggest": { diff --git a/composer.lock b/composer.lock index 2e1fdaced..466cd983f 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": "983eaacb5443e19a04f1e119184b1e57", + "content-hash": "2587e14c10bc64959963a6f91f5ada71", "packages": [ { "name": "composer/ca-bundle", From 8427b6c8ed335a09a7b03e8ee45bd12c788135ad Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 20 May 2021 13:27:15 +0200 Subject: [PATCH 2/4] Also make sure filesystem is up to date before generating binary links, refs #9627 --- src/Composer/Installer/BinaryInstaller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 47022ff42..259c43db1 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -53,6 +53,9 @@ class BinaryInstaller if (!$binaries) { return; } + + Platform::workaroundFilesystemIssues(); + foreach ($binaries as $bin) { $binPath = $installPath.'/'.$bin; if (!file_exists($binPath)) { From 251b852fd24cd88feb98020acf3c139bc44e01a6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 20 May 2021 14:15:14 +0200 Subject: [PATCH 3/4] Make sure async processes fail the promise if they fail to start, fixes #9808 --- src/Composer/Util/ProcessExecutor.php | 28 +++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 6b3c4fe0f..8c982a191 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -250,16 +250,32 @@ class ProcessExecutor throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd); } - // TODO in v3, commands should be passed in as arrays of cmd + args - if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { - $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); - } else { - $process = new Process($command, $cwd, null, null, static::getTimeout()); + try { + // TODO in v3, commands should be passed in as arrays of cmd + args + if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { + $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); + } else { + $process = new Process($command, $cwd, null, null, static::getTimeout()); + } + } catch (\Exception $e) { + call_user_func($job['reject'], $e); + return; + } catch (\Throwable $e) { + call_user_func($job['reject'], $e); + return; } $job['process'] = $process; - $process->start(); + try { + $process->start(); + } catch (\Exception $e) { + call_user_func($job['reject'], $e); + return; + } catch (\Throwable $e) { + call_user_func($job['reject'], $e); + return; + } } public function wait($index = null) From 8d8842eb8cd72807d22dbd98dedb5eaec4e7f6a7 Mon Sep 17 00:00:00 2001 From: Guilliam Xavier Date: Thu, 20 May 2021 11:04:19 +0200 Subject: [PATCH 4/4] Fix schema minimum-stability pattern --- .github/CONTRIBUTING.md | 2 +- res/composer-schema.json | 6 ++--- .../Composer/Test/Json/ComposerSchemaTest.php | 26 +++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8f525a97f..7f161bd79 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -41,7 +41,7 @@ To achieve this, you need to acquire the Composer source code: 2. Download the [`composer.phar`](https://getcomposer.org/composer.phar) executable 3. Run Composer to get the dependencies: `cd composer && php ../composer.phar install` -You can run the test suite by executing `vendor/bin/phpunit` when inside the +You can run the test suite by executing `vendor/bin/simple-phpunit` when inside the composer directory, and run Composer by executing the `bin/composer`. To test your modified Composer code against another project, run `php /path/to/composer/bin/composer` inside that project's directory. diff --git a/res/composer-schema.json b/res/composer-schema.json index 7aa8fbd1a..c5e3376ee 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft-04/schema#", - "name": "Package", + "title": "Package", "type": "object", "additionalProperties": false, "required": [ "name", "description" ], @@ -42,7 +42,7 @@ "version": { "type": "string", "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.", - "pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-" + "pattern": "^v?\\d+(\\.\\d+){0,3}|^dev-" }, "time": { "type": "string", @@ -397,7 +397,7 @@ "minimum-stability": { "type": ["string"], "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.", - "pattern": "^dev|alpha|beta|rc|RC|stable$" + "enum": ["dev", "alpha", "beta", "rc", "RC", "stable"] }, "prefer-stable": { "type": ["boolean"], diff --git a/tests/Composer/Test/Json/ComposerSchemaTest.php b/tests/Composer/Test/Json/ComposerSchemaTest.php index 687c1137a..0eece664c 100644 --- a/tests/Composer/Test/Json/ComposerSchemaTest.php +++ b/tests/Composer/Test/Json/ComposerSchemaTest.php @@ -71,25 +71,23 @@ class ComposerSchemaTest extends TestCase public function testMinimumStabilityValues() { - $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "" }'; - $this->assertEquals(array( + $expectedError = array( array( 'property' => 'minimum-stability', - 'message' => 'Does not match the regex pattern ^dev|alpha|beta|rc|RC|stable$', - 'constraint' => 'pattern', - 'pattern' => '^dev|alpha|beta|rc|RC|stable$', + 'message' => 'Does not have a value in the enumeration ["dev","alpha","beta","rc","RC","stable"]', + 'constraint' => 'enum', + 'enum' => array('dev', 'alpha', 'beta', 'rc', 'RC', 'stable'), ), - ), $this->check($json), 'empty string'); + ); + + $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "" }'; + $this->assertEquals($expectedError, $this->check($json), 'empty string'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "dummy" }'; - $this->assertEquals(array( - array( - 'property' => 'minimum-stability', - 'message' => 'Does not match the regex pattern ^dev|alpha|beta|rc|RC|stable$', - 'constraint' => 'pattern', - 'pattern' => '^dev|alpha|beta|rc|RC|stable$', - ), - ), $this->check($json), 'dummy'); + $this->assertEquals($expectedError, $this->check($json), 'dummy'); + + $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "devz" }'; + $this->assertEquals($expectedError, $this->check($json), 'devz'); $json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "dev" }'; $this->assertTrue($this->check($json), 'dev');