From 96acad1e45555380a8ca90767b3bc00a2f44bf4f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 09:13:32 +0200 Subject: [PATCH 1/6] Update github token pattern to match their latest updates --- src/Composer/Util/ProcessExecutor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index cb1886e94..658c2a136 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -45,8 +45,8 @@ class ProcessExecutor { if ($this->io && $this->io->isDebug()) { $safeCommand = preg_replace_callback('{://(?P[^:/\s]+):(?P[^@\s/]+)@}i', function ($m) { - // if the username looks like a long (12char+) hex string, or a modern github token (e.g. gp1_xxx) we obfuscate that - if (preg_match('{^([a-f0-9]{12,}|g[a-z]\d_[a-zA-Z0-9_]+)$}', $m['user'])) { + // if the username looks like a long (12char+) hex string, or a modern github token (e.g. ghp_xxx) we obfuscate that + if (preg_match('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) { return '://***:***@'; } From 4dc293b289fd12a28a3f13780339a0393f094d7c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 09:16:28 +0200 Subject: [PATCH 2/6] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96f476eec..844f1b5e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### [1.10.21] 2021-04-01 + + * Fixed support for new GitHub OAuth token format + * Fixed processes silently ignoring the CWD when it does not exist + ### [1.10.20] 2021-01-27 * Fixed exclude-from-classmap causing regex issues when having too many paths @@ -929,6 +934,7 @@ * Initial release +[1.10.21]: https://github.com/composer/composer/compare/1.10.20...1.10.21 [1.10.20]: https://github.com/composer/composer/compare/1.10.19...1.10.20 [1.10.19]: https://github.com/composer/composer/compare/1.10.18...1.10.19 [1.10.18]: https://github.com/composer/composer/compare/1.10.17...1.10.18 From 53a974f9c9f56dce6f9f237fb5c20da0cff5066e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 09:48:07 +0200 Subject: [PATCH 3/6] Tweak virtualbox detection and improve it by detecting vbox additions, refs #9627 --- doc/03-cli.md | 9 ++++++++ src/Composer/Util/Platform.php | 39 +++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/doc/03-cli.md b/doc/03-cli.md index 99d4272b8..63e565d57 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -998,6 +998,15 @@ cannot be guessed from VCS info and is not present in `composer.json`. By setting this var you can make Composer install the dependencies into a directory other than `vendor`. +### COMPOSER_RUNTIME_ENV + +This lets you hint under which environment Composer is running, which can help Composer +work around some environment specific issues. The only value currently supported is +`virtualbox`, which then enables some short `sleep()` calls to wait for the filesystem +to have written files properly before we attempt reading them. You can set the +environment variable if you use Vagrant or VirtualBox and experience issues with files not +being found during installation even though they should be present. + ### http_proxy or HTTP_PROXY If you are using Composer from behind an HTTP proxy, you can use the standard diff --git a/src/Composer/Util/Platform.php b/src/Composer/Util/Platform.php index a18af5356..6293ce80c 100644 --- a/src/Composer/Util/Platform.php +++ b/src/Composer/Util/Platform.php @@ -20,7 +20,7 @@ namespace Composer\Util; class Platform { /** @var ?bool */ - private static $isVagrantGuest = null; + private static $isVirtualBoxGuest = null; /** * Parses tildes and environment variables in paths. @@ -123,34 +123,49 @@ class Platform public static function workaroundFilesystemIssues() { - if (self::isVagrantGuest()) { + if (self::isVirtualBoxGuest()) { usleep(200000); } } /** - * Attempts detection of vagrant guest VMs + * Attempts detection of VirtualBox guest VMs * - * This works based on the process' user being "vagrant", or the COMPOSER_RUNTIME_ENV env var being set to "vagrant" + * This works based on the process' user being "vagrant", the COMPOSER_RUNTIME_ENV env var being set to "virtualbox", or lsmod showing the virtualbox guest additions are loaded * * @return bool */ - private static function isVagrantGuest() + private static function isVirtualBoxGuest() { - if (null === self::$isVagrantGuest) { - self::$isVagrantGuest = false; - if (!self::isWindows() && function_exists('posix_getpwuid') && function_exists('posix_geteuid')) { + if (null === self::$isVirtualBoxGuest) { + self::$isVirtualBoxGuest = false; + if (self::isWindows()) { + return self::$isVirtualBoxGuest; + } + + if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) { $processUser = posix_getpwuid(posix_geteuid()); if ($processUser && $processUser['name'] === 'vagrant') { - return self::$isVagrantGuest = true; + return self::$isVirtualBoxGuest = true; } } - if (getenv('COMPOSER_RUNTIME_ENV') === 'vagrant') { - return self::$isVagrantGuest = true; + if (getenv('COMPOSER_RUNTIME_ENV') === 'virtualbox') { + return self::$isVirtualBoxGuest = true; + } + + if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') { + $process = new ProcessExecutor(); + try { + if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) { + return self::$isVirtualBoxGuest = true; + } + } catch (\Exception $e) { + // noop + } } } - return self::$isVagrantGuest; + return self::$isVirtualBoxGuest; } } From 7b8a15d648424fd15ecb69b43531486b884b5ce2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 09:59:45 +0200 Subject: [PATCH 4/6] Update changelog --- CHANGELOG.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a648f25d7..04a473d38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ -<<<<<<< HEAD +### [2.0.12] 2021-04-01 + + * Fixed support for new GitHub OAuth token format (#9757) + * Fixed support for Vagrant/VirtualBox filesystem slowness by adding short sleeps in some places (#9627) + * Fixed unclear error reporting when a package is in the lock file but not in the remote repositories (#9750) + * Fixed processes silently ignoring the CWD when it does not exist + * Fixed new Windows bin handling to avoid proxying phar files (#9742) + * Fixed issue extracting archives into paths that already exist, fixing problems with some custom installers (composer/installers#479) + * Fixed support for branch names starting with master/trunk/default (#9739) + * Fixed self-update to preserve phar file permissions on Windows (#9733) + * Fixed git execution failures to also include the stdout output (#9720) + ### [2.0.11] 2021-02-24 * Reverted "Fixed runtime autoloader registration (for plugins and script handlers) to prefer the project dependencies over the bundled Composer ones" as it caused more problems than expected @@ -183,12 +194,11 @@ * Fixed package ordering when autoloading and especially when loading plugins, to make sure dependencies are loaded before their dependents * Fixed suggest output being very spammy, it now is only one line long and shows more rarely * Fixed conflict rules like e.g. >=5 from matching dev-master, as it is not normalized to 9999999-dev internally anymore -======= + ### [1.10.21] 2021-04-01 * Fixed support for new GitHub OAuth token format * Fixed processes silently ignoring the CWD when it does not exist ->>>>>>> 1.10 ### [1.10.20] 2021-01-27 @@ -1121,6 +1131,7 @@ * Initial release +[2.0.12]: https://github.com/composer/composer/compare/2.0.11...2.0.12 [2.0.11]: https://github.com/composer/composer/compare/2.0.10...2.0.11 [2.0.10]: https://github.com/composer/composer/compare/2.0.9...2.0.10 [2.0.9]: https://github.com/composer/composer/compare/2.0.8...2.0.9 From dc84dbbbf708920a0b42b5c0b6699c964d8286df Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 10:09:49 +0200 Subject: [PATCH 5/6] Fixed detection of hg version when localized, fixes #9753 --- CHANGELOG.md | 3 ++- src/Composer/Util/Hg.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a473d38..9b7fc7b14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,14 @@ ### [2.0.12] 2021-04-01 * Fixed support for new GitHub OAuth token format (#9757) - * Fixed support for Vagrant/VirtualBox filesystem slowness by adding short sleeps in some places (#9627) + * Fixed support for Vagrant/VirtualBox filesystem slowness by adding short sleeps in some places (#9627) * Fixed unclear error reporting when a package is in the lock file but not in the remote repositories (#9750) * Fixed processes silently ignoring the CWD when it does not exist * Fixed new Windows bin handling to avoid proxying phar files (#9742) * Fixed issue extracting archives into paths that already exist, fixing problems with some custom installers (composer/installers#479) * Fixed support for branch names starting with master/trunk/default (#9739) * Fixed self-update to preserve phar file permissions on Windows (#9733) + * Fixed detection of hg version when localized (#9753) * Fixed git execution failures to also include the stdout output (#9720) ### [2.0.11] 2021-02-24 diff --git a/src/Composer/Util/Hg.php b/src/Composer/Util/Hg.php index a0ebac01d..fe0649dbb 100644 --- a/src/Composer/Util/Hg.php +++ b/src/Composer/Util/Hg.php @@ -92,7 +92,7 @@ class Hg { if (false === self::$version) { self::$version = null; - if (0 === $process->execute('hg --version', $output) && preg_match('/version (\d+(?:\.\d+)+)/m', $output, $matches)) { + if (0 === $process->execute('hg --version', $output) && preg_match('/^.+? (\d+(?:\.\d+)+)\)?\r?\n/', $output, $matches)) { self::$version = $matches[1]; } } From 18e268556dcdadff3d9cd5ed9290fa7d647efb07 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 10:14:21 +0200 Subject: [PATCH 6/6] Fix type warning on php8.1, refs #9770 --- src/Composer/Command/CreateProjectCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index d7cfd1039..a1ad373b5 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -343,7 +343,9 @@ EOT } if (null === $stability) { - if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) { + if (null === $packageVersion) { + $stability = 'stable'; + } elseif (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) { $stability = $match[1]; } else { $stability = VersionParser::parseStability($packageVersion);