From 6473dd91850460b9825fa8300b71e7712618bafe Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 27 Feb 2019 15:03:25 +0100 Subject: [PATCH 01/12] Minor improvements to VersionCacheInterface --- src/Composer/Repository/VcsRepository.php | 28 +++++++++++++++++++ .../Repository/VersionCacheInterface.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index d6fb1bbee..9a9ba5833 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -43,6 +43,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt private $driver; /** @var VersionCacheInterface */ private $versionCache; + private $emptyReferences = array(); public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, array $drivers = null, VersionCacheInterface $versionCache = null) { @@ -117,6 +118,11 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt return $this->branchErrorOccurred; } + public function getEmptyReferences() + { + return $this->emptyReferences; + } + protected function initialize() { parent::initialize(); @@ -159,6 +165,10 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt if ($cachedPackage) { $this->addPackage($cachedPackage); + continue; + } elseif ($cachedPackage === false) { + $this->emptyReferences[] = $identifier; + continue; } @@ -174,6 +184,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt if ($verbose) { $this->io->writeError('Skipped tag '.$tag.', no composer file'); } + $this->emptyReferences[] = $identifier; continue; } @@ -212,6 +223,9 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier))); } catch (\Exception $e) { + if ($e instanceof TransportException) { + $this->emptyReferences[] = $identifier; + } if ($verbose) { $this->io->writeError('Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).''); } @@ -258,6 +272,10 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt if ($cachedPackage) { $this->addPackage($cachedPackage); + continue; + } elseif ($cachedPackage === false) { + $this->emptyReferences[] = $identifier; + continue; } @@ -266,6 +284,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt if ($verbose) { $this->io->writeError('Skipped branch '.$branch.', no composer file'); } + $this->emptyReferences[] = $identifier; continue; } @@ -284,6 +303,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt } $this->addPackage($package); } catch (TransportException $e) { + $this->emptyReferences[] = $identifier; if ($verbose) { $this->io->writeError('Skipped branch '.$branch.', no composer file was found'); } @@ -352,6 +372,14 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt } $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier); + if ($cachedPackage === false) { + if ($verbose) { + $this->io->writeError('Skipped '.$version.', no composer file (cached from ref '.$identifier.')'); + } + + return false; + } + if ($cachedPackage) { $msg = 'Found cached composer.json of ' . ($this->packageName ?: $this->url) . ' (' . $version . ')'; if ($verbose) { diff --git a/src/Composer/Repository/VersionCacheInterface.php b/src/Composer/Repository/VersionCacheInterface.php index db5934b59..41d485c64 100644 --- a/src/Composer/Repository/VersionCacheInterface.php +++ b/src/Composer/Repository/VersionCacheInterface.php @@ -17,7 +17,7 @@ interface VersionCacheInterface /** * @param string $version * @param string $identifier - * @return array Package version data + * @return array|null|false Package version data if found, false to indicate the identifier is known but has no package, null for an unknown identifier */ public function getVersionPackage($version, $identifier); } From 6bce9da8c87450c9a08c217e1a4e6142087b4cf5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 4 Mar 2019 08:53:18 +0100 Subject: [PATCH 02/12] Only keep track of empty references that returned a 404 --- src/Composer/Repository/VcsRepository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index 9a9ba5833..edd0dabf8 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -223,7 +223,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier))); } catch (\Exception $e) { - if ($e instanceof TransportException) { + if ($e instanceof TransportException && $e->getCode() === 404) { $this->emptyReferences[] = $identifier; } if ($verbose) { @@ -303,7 +303,9 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt } $this->addPackage($package); } catch (TransportException $e) { - $this->emptyReferences[] = $identifier; + if ($e->getCode() === 404) { + $this->emptyReferences[] = $identifier; + } if ($verbose) { $this->io->writeError('Skipped branch '.$branch.', no composer file was found'); } From d96d046209646e93259d54ca9985004341c40fe2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 4 Mar 2019 11:38:58 +0100 Subject: [PATCH 03/12] Fix require of platform packages with --ignore-platform-reqs, fixes #8012 --- src/Composer/Command/InitCommand.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index abcea73b2..ecc3d3238 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -694,15 +694,22 @@ EOT { // find the latest version allowed in this pool $versionSelector = new VersionSelector($this->getPool($input, $minimumStability)); - $package = $versionSelector->findBestCandidate($name, $requiredVersion, $phpVersion, $preferredStability); + $ignorePlatformReqs = $input->hasOption('ignore-platform-reqs') && $input->getOption('ignore-platform-reqs'); - // retry without phpVersion if platform requirements are ignored in case nothing was found - if ($input->hasOption('ignore-platform-reqs') && $input->getOption('ignore-platform-reqs')) { + // ignore phpVersion if platform requirements are ignored + if ($ignorePlatformReqs) { $phpVersion = null; - $package = $versionSelector->findBestCandidate($name, $requiredVersion, $phpVersion, $preferredStability); } + $package = $versionSelector->findBestCandidate($name, $requiredVersion, $phpVersion, $preferredStability); + if (!$package) { + // platform packages can not be found in the pool in versions other than the local platform's has + // so if platform reqs are ignored we just take the user's word for it + if ($ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) { + return array($name, $requiredVersion ?: '*'); + } + // Check whether the PHP version was the problem if ($phpVersion && $versionSelector->findBestCandidate($name, $requiredVersion, null, $preferredStability)) { throw new \InvalidArgumentException(sprintf( From c876613d5c651d1aa0f0d6621d7955bfe09520e2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 4 Mar 2019 12:55:38 +0100 Subject: [PATCH 04/12] Added "Read more at" links to all commands (#8019) --- src/Composer/Command/ArchiveCommand.php | 1 + src/Composer/Command/ClearCacheCommand.php | 2 ++ src/Composer/Command/ConfigCommand.php | 2 ++ src/Composer/Command/CreateProjectCommand.php | 1 + src/Composer/Command/DependsCommand.php | 1 + src/Composer/Command/DiagnoseCommand.php | 1 + src/Composer/Command/DumpAutoloadCommand.php | 2 ++ src/Composer/Command/ExecCommand.php | 7 +++++++ src/Composer/Command/GlobalCommand.php | 1 + src/Composer/Command/HomeCommand.php | 2 ++ src/Composer/Command/InitCommand.php | 1 + src/Composer/Command/InstallCommand.php | 1 + src/Composer/Command/LicensesCommand.php | 1 + src/Composer/Command/OutdatedCommand.php | 2 +- src/Composer/Command/ProhibitsCommand.php | 1 + src/Composer/Command/RemoveCommand.php | 1 + src/Composer/Command/RequireCommand.php | 1 + src/Composer/Command/RunScriptCommand.php | 2 ++ src/Composer/Command/ScriptAliasCommand.php | 2 ++ src/Composer/Command/SearchCommand.php | 1 + src/Composer/Command/SelfUpdateCommand.php | 1 + src/Composer/Command/ShowCommand.php | 1 + src/Composer/Command/StatusCommand.php | 1 + src/Composer/Command/SuggestsCommand.php | 1 + src/Composer/Command/UpdateCommand.php | 1 + src/Composer/Command/ValidateCommand.php | 1 + 26 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index 29858c6fc..d0d9542cb 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -56,6 +56,7 @@ package in the specified version and writes it to the specified directory. php composer.phar archive [--format=zip] [--dir=/foo] [package [version]] +Read more at https://getcomposer.org/doc/03-cli.md#archive EOT ) ; diff --git a/src/Composer/Command/ClearCacheCommand.php b/src/Composer/Command/ClearCacheCommand.php index 2514f6330..ec51c56d3 100644 --- a/src/Composer/Command/ClearCacheCommand.php +++ b/src/Composer/Command/ClearCacheCommand.php @@ -32,6 +32,8 @@ class ClearCacheCommand extends BaseCommand <<clear-cache deletes all cached packages from composer's cache directory. + +Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache- EOT ) ; diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index c2347d306..b7e3b1f99 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -125,6 +125,8 @@ You can always pass more than one option. As an example, if you want to edit the global config.json file. %command.full_name% --editor --global + +Read more at https://getcomposer.org/doc/03-cli.md#config EOT ) ; diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index cca5f1871..3702c3595 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -104,6 +104,7 @@ controlled code by appending the '--prefer-source' flag. To install a package from another repository than the default one you can pass the '--repository=https://myrepository.org' flag. +Read more at https://getcomposer.org/doc/03-cli.md#create-project EOT ) ; diff --git a/src/Composer/Command/DependsCommand.php b/src/Composer/Command/DependsCommand.php index acbc89a70..d6adec083 100644 --- a/src/Composer/Command/DependsCommand.php +++ b/src/Composer/Command/DependsCommand.php @@ -37,6 +37,7 @@ Displays detailed information about where a package is referenced. php composer.phar depends composer/composer +Read more at https://getcomposer.org/doc/03-cli.md#depends-why- EOT ) ; diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 3c4c3bb32..19ed81392 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -55,6 +55,7 @@ The diagnose command checks common errors to help debugging problem The process exit code will be 1 in case of warnings and 2 for errors. +Read more at https://getcomposer.org/doc/03-cli.md#diagnose EOT ) ; diff --git a/src/Composer/Command/DumpAutoloadCommand.php b/src/Composer/Command/DumpAutoloadCommand.php index 55a2c5f16..3add15166 100644 --- a/src/Composer/Command/DumpAutoloadCommand.php +++ b/src/Composer/Command/DumpAutoloadCommand.php @@ -39,6 +39,8 @@ class DumpAutoloadCommand extends BaseCommand ->setHelp( <<php composer.phar dump-autoload + +Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload- EOT ) ; diff --git a/src/Composer/Command/ExecCommand.php b/src/Composer/Command/ExecCommand.php index f07bc9d28..c9184c707 100644 --- a/src/Composer/Command/ExecCommand.php +++ b/src/Composer/Command/ExecCommand.php @@ -36,6 +36,13 @@ class ExecCommand extends BaseCommand 'Arguments to pass to the binary. Use -- to separate from composer arguments' ), )) + ->setHelp( + <</.config/composer Note: This path may vary depending on customizations to bin-dir in composer.json or the environmental variable COMPOSER_BIN_DIR. +Read more at https://getcomposer.org/doc/03-cli.md#global EOT ) ; diff --git a/src/Composer/Command/HomeCommand.php b/src/Composer/Command/HomeCommand.php index a2f0756a1..b7d907066 100644 --- a/src/Composer/Command/HomeCommand.php +++ b/src/Composer/Command/HomeCommand.php @@ -49,6 +49,8 @@ homepage in your default browser. To open the homepage by default, use -H or --homepage. To show instead of open the repository or homepage URL, use -s or --show. + +Read more at https://getcomposer.org/doc/03-cli.md#browse-home EOT ); } diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index ecc3d3238..66a56f978 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -72,6 +72,7 @@ in the current directory. php composer.phar init +Read more at https://getcomposer.org/doc/03-cli.md#init EOT ) ; diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index cc590d8c9..32fb1bdc6 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -61,6 +61,7 @@ exist it will look for composer.json and do the same. php composer.phar install +Read more at https://getcomposer.org/doc/03-cli.md#install-i EOT ) ; diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index 9dec45e1b..b3c30d63b 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -41,6 +41,7 @@ class LicensesCommand extends BaseCommand The license command displays detailed information about the licenses of the installed dependencies. +Read more at https://getcomposer.org/doc/03-cli.md#licenses EOT ) ; diff --git a/src/Composer/Command/OutdatedCommand.php b/src/Composer/Command/OutdatedCommand.php index 79409c58f..ae26a7487 100644 --- a/src/Composer/Command/OutdatedCommand.php +++ b/src/Composer/Command/OutdatedCommand.php @@ -50,7 +50,7 @@ The color coding (or signage if you have ANSI colors disabled) for dependency ve may involve work. - red (!): Dependency has a new version that is semver-compatible and you should upgrade it. - +Read more at https://getcomposer.org/doc/03-cli.md#outdated EOT ) ; diff --git a/src/Composer/Command/ProhibitsCommand.php b/src/Composer/Command/ProhibitsCommand.php index edf6729ab..9e5575c74 100644 --- a/src/Composer/Command/ProhibitsCommand.php +++ b/src/Composer/Command/ProhibitsCommand.php @@ -37,6 +37,7 @@ Displays detailed information about why a package cannot be installed. php composer.phar prohibits composer/composer +Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not- EOT ) ; diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index 27be1a0ca..e4407d4cb 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -56,6 +56,7 @@ list of installed packages php composer.phar remove +Read more at https://getcomposer.org/doc/03-cli.md#remove EOT ) ; diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index b347de094..4cad91023 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -73,6 +73,7 @@ If you do not specify a version constraint, composer will choose a suitable one If you do not want to install the new dependencies immediately you can call it with --no-update +Read more at https://getcomposer.org/doc/03-cli.md#require EOT ) ; diff --git a/src/Composer/Command/RunScriptCommand.php b/src/Composer/Command/RunScriptCommand.php index ea3b5c892..6d39ce6da 100644 --- a/src/Composer/Command/RunScriptCommand.php +++ b/src/Composer/Command/RunScriptCommand.php @@ -62,6 +62,8 @@ class RunScriptCommand extends BaseCommand The run-script command runs scripts defined in composer.json: php composer.phar run-script post-update-cmd + +Read more at https://getcomposer.org/doc/03-cli.md#run-script EOT ) ; diff --git a/src/Composer/Command/ScriptAliasCommand.php b/src/Composer/Command/ScriptAliasCommand.php index 1aba0b074..455f7420c 100644 --- a/src/Composer/Command/ScriptAliasCommand.php +++ b/src/Composer/Command/ScriptAliasCommand.php @@ -48,6 +48,8 @@ class ScriptAliasCommand extends BaseCommand The run-script command runs scripts defined in composer.json: php composer.phar run-script post-update-cmd + +Read more at https://getcomposer.org/doc/03-cli.md#run-script EOT ) ; diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index ed180e84c..54aa4dcea 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -49,6 +49,7 @@ class SearchCommand extends BaseCommand The search command searches for packages by its name php composer.phar search symfony composer +Read more at https://getcomposer.org/doc/03-cli.md#search EOT ) ; diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 243755963..78b27460e 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -60,6 +60,7 @@ versions of composer and if found, installs the latest. php composer.phar self-update +Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate- EOT ) ; diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index cc0fe0154..e9061743f 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -85,6 +85,7 @@ class ShowCommand extends BaseCommand The show command displays detailed information about a package, or lists all packages available. +Read more at https://getcomposer.org/doc/03-cli.md#show EOT ) ; diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php index 3e46b7fa0..cd153fc58 100644 --- a/src/Composer/Command/StatusCommand.php +++ b/src/Composer/Command/StatusCommand.php @@ -52,6 +52,7 @@ class StatusCommand extends BaseCommand The status command displays a list of dependencies that have been modified locally. +Read more at https://getcomposer.org/doc/03-cli.md#status EOT ) ; diff --git a/src/Composer/Command/SuggestsCommand.php b/src/Composer/Command/SuggestsCommand.php index 225725e12..a200f8f69 100644 --- a/src/Composer/Command/SuggestsCommand.php +++ b/src/Composer/Command/SuggestsCommand.php @@ -38,6 +38,7 @@ The %command.name% command shows a sorted list of suggested package Enabling -v implies --by-package --by-suggestion, showing both lists. +Read more at https://getcomposer.org/doc/03-cli.md#suggests EOT ) ; diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 34420b747..e68c265c0 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -81,6 +81,7 @@ from a specific vendor: To select packages names interactively with auto-completion use -i. +Read more at https://getcomposer.org/doc/03-cli.md#update-u EOT ) ; diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php index 52023e528..5aba74adf 100644 --- a/src/Composer/Command/ValidateCommand.php +++ b/src/Composer/Command/ValidateCommand.php @@ -55,6 +55,7 @@ Exit codes in case of errors are: 2 validation error(s) 3 file unreadable or missing +Read more at https://getcomposer.org/doc/03-cli.md#validate EOT ); } From 20ff8b22f29ecb7422f756a86347d7562e17b935 Mon Sep 17 00:00:00 2001 From: Mike Hatch <4390485+mikeshatch@users.noreply.github.com> Date: Sat, 9 Mar 2019 00:27:34 -0600 Subject: [PATCH 05/12] Corrected a typo and two grammar errors. --- doc/00-intro.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/00-intro.md b/doc/00-intro.md index e4af54c2c..ed7a17c7c 100644 --- a/doc/00-intro.md +++ b/doc/00-intro.md @@ -10,7 +10,7 @@ Composer is **not** a package manager in the same sense as Yum or Apt are. Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. `vendor`) inside your project. By default it does not install anything globally. Thus, it is a dependency -manager. It does however support a "global" project for convenience via the +manager. It does however support a "global" project for convenience via the [global](03-cli.md#global) command. This idea is not new and Composer is strongly inspired by node's @@ -47,7 +47,7 @@ Linux and macOS. ### Downloading the Composer Executable Composer offers a convenient installer that you can execute directly from the -commandline. Feel free to [download this file](https://getcomposer.org/installer) +command line. Feel free to [download this file](https://getcomposer.org/installer) or review it on [GitHub](https://github.com/composer/getcomposer.org/blob/master/web/installer) if you wish to know more about the inner workings of the installer. The source is plain PHP. @@ -82,7 +82,7 @@ Now run `php bin/composer` in order to run Composer. #### Globally You can place the Composer PHAR anywhere you wish. If you put it in a directory -that is part of your `PATH`, you can access it globally. On unixy systems you +that is part of your `PATH`, you can access it globally. On Unix systems you can even make it executable and invoke it without directly using the `php` interpreter. From 7c64300a1b4516fe8693ef17c690edafd25b716d Mon Sep 17 00:00:00 2001 From: Christian Ego Date: Mon, 11 Mar 2019 10:24:39 +0100 Subject: [PATCH 06/12] using emptyDirectory instead of remove for clearing the cache --- src/Composer/Cache.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index 3f2861797..06c6a0996 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -189,7 +189,8 @@ class Cache public function clear() { if ($this->enabled) { - return $this->filesystem->removeDirectory($this->root); + $this->filesystem->emptyDirectory($this->root); + return true; } return false; From 486b25fd3015dc21df0524178d0ad279c91c8980 Mon Sep 17 00:00:00 2001 From: Novicaine Date: Fri, 15 Mar 2019 13:15:01 -0500 Subject: [PATCH 07/12] Fix for UNC Windows paths Made isAbsolutePath recognize Windows UNC-style absolute paths starting with \\ --- src/Composer/Util/Filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 1903f1c8d..d9e83280b 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -440,7 +440,7 @@ class Filesystem */ public function isAbsolutePath($path) { - return substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':'; + return substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':' || substr($path,0,2) === '\\'; } /** From 077bbe33729f0a794052f1c7966e7f15211e3b41 Mon Sep 17 00:00:00 2001 From: Quynh Xuan Nguyen Date: Tue, 19 Mar 2019 11:20:21 +0700 Subject: [PATCH 08/12] Correct description grammar --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5ed969969..0878f5b65 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "composer/composer", "type": "library", - "description": "Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.", + "description": "Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.", "keywords": [ "package", "dependency", From 8944627245b66948111a33f467b7c865115c559b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 19 Mar 2019 11:34:23 +0100 Subject: [PATCH 09/12] Fix syntax and backslash escaping --- src/Composer/Util/Filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index d9e83280b..c025a6b8c 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -440,7 +440,7 @@ class Filesystem */ public function isAbsolutePath($path) { - return substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':' || substr($path,0,2) === '\\'; + return substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':' || substr($path, 0, 2) === '\\\\'; } /** From 4441be1a0536789b28bea20c3a86cbcac852a0d2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 19 Mar 2019 18:31:12 +0100 Subject: [PATCH 10/12] Update deps --- composer.lock | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/composer.lock b/composer.lock index d0f72d83c..44b30fa22 100644 --- a/composer.lock +++ b/composer.lock @@ -64,16 +64,16 @@ }, { "name": "composer/semver", - "version": "1.4.2", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573" + "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573", - "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573", + "url": "https://api.github.com/repos/composer/semver/zipball/46d9139568ccb8d9e7cdd4539cab7347568a5e2e", + "reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e", "shasum": "" }, "require": { @@ -122,7 +122,7 @@ "validation", "versioning" ], - "time": "2016-08-30T16:08:34+00:00" + "time": "2019-03-19T17:25:45+00:00" }, { "name": "composer/spdx-licenses", @@ -231,23 +231,23 @@ }, { "name": "justinrainbow/json-schema", - "version": "5.2.7", + "version": "5.2.8", "source": { "type": "git", "url": "https://github.com/justinrainbow/json-schema.git", - "reference": "8560d4314577199ba51bf2032f02cd1315587c23" + "reference": "dcb6e1006bb5fd1e392b4daa68932880f37550d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/8560d4314577199ba51bf2032f02cd1315587c23", - "reference": "8560d4314577199ba51bf2032f02cd1315587c23", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/dcb6e1006bb5fd1e392b4daa68932880f37550d4", + "reference": "dcb6e1006bb5fd1e392b4daa68932880f37550d4", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.1", + "friendsofphp/php-cs-fixer": "~2.2.20", "json-schema/json-schema-test-suite": "1.2.0", "phpunit/phpunit": "^4.8.35" }, @@ -293,7 +293,7 @@ "json", "schema" ], - "time": "2018-02-14T22:26:30+00:00" + "time": "2019-01-14T23:55:14+00:00" }, { "name": "psr/log", @@ -437,7 +437,7 @@ }, { "name": "symfony/console", - "version": "v2.8.48", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/console.git", @@ -498,7 +498,7 @@ }, { "name": "symfony/debug", - "version": "v2.8.48", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", @@ -555,7 +555,7 @@ }, { "name": "symfony/filesystem", - "version": "v2.8.48", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", @@ -605,7 +605,7 @@ }, { "name": "symfony/finder", - "version": "v2.8.48", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -771,7 +771,7 @@ }, { "name": "symfony/process", - "version": "v2.8.48", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -1360,6 +1360,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2015-10-02T06:51:40+00:00" }, { @@ -1736,7 +1737,7 @@ }, { "name": "symfony/yaml", - "version": "v2.8.48", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", From fb8b06edef6fee799344aac0ef342e0846ef4974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Thu, 21 Mar 2019 19:44:49 +0100 Subject: [PATCH 11/12] Remove unused local variable --- src/Composer/DependencyResolver/Problem.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 073f64e2d..0dcc938fd 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -79,7 +79,6 @@ class Problem reset($reasons); $reason = current($reasons); - $rule = $reason['rule']; $job = $reason['job']; if (isset($job['constraint'])) { From 625bcee63a58e17cd6e2cc981e76541ea526040e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 1 Apr 2019 17:56:03 +0200 Subject: [PATCH 12/12] Fix handling of warnings to incl all 4xx responses --- .../Repository/ComposerRepository.php | 24 +---------- src/Composer/Util/RemoteFilesystem.php | 40 +++++++++++++------ 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index b9de0d7ea..38b865103 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -700,7 +700,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito } $data = JsonFile::parseJson($json, $filename); - $this->outputWarnings($data); + RemoteFilesystem::outputWarnings($this->io, $this->url, $data); if ($cacheKey) { if ($storeLastModifiedTime) { @@ -765,7 +765,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito } $data = JsonFile::parseJson($json, $filename); - $this->outputWarnings($data); + RemoteFilesystem::outputWarnings($this->io, $this->url, $data); $lastModifiedDate = $rfs->findHeaderValue($rfs->getLastHeaders(), 'last-modified'); if ($lastModifiedDate) { @@ -826,24 +826,4 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito // wipe rootData as it is fully consumed at this point and this saves some memory $this->rootData = true; } - - private function outputWarnings($data) - { - foreach (array('warning', 'info') as $type) { - if (empty($data[$type])) { - continue; - } - - if (!empty($data[$type . '-versions'])) { - $versionParser = new VersionParser(); - $constraint = $versionParser->parseConstraints($data[$type . '-versions']); - $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion())); - if (!$constraint->matches($composer)) { - continue; - } - } - - $this->io->writeError('<'.$type.'>'.ucfirst($type).' from '.$this->url.': '.$data[$type].''); - } - } } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index ea18a9e30..e1a93fcf9 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -13,6 +13,9 @@ namespace Composer\Util; use Composer\Config; +use Composer\Composer; +use Composer\Semver\Constraint\Constraint; +use Composer\Package\Version\VersionParser; use Composer\IO\IOInterface; use Composer\Downloader\TransportException; use Composer\CaBundle\CaBundle; @@ -324,15 +327,12 @@ class RemoteFilesystem if (!empty($http_response_header[0])) { $statusCode = $this->findStatusCode($http_response_header); + if ($statusCode >= 400 && $this->findHeaderValue($http_response_header, 'content-type') === 'application/json') { + self::outputWarnings($this->io, $originUrl, json_decode($result, true)); + } + if (in_array($statusCode, array(401, 403)) && $this->retryAuthFailure) { - $warning = null; - if ($this->findHeaderValue($http_response_header, 'content-type') === 'application/json') { - $data = json_decode($result, true); - if (!empty($data['warning'])) { - $warning = $data['warning']; - } - } - $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $warning, $http_response_header); + $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), null, $http_response_header); } } @@ -741,10 +741,6 @@ class RemoteFilesystem throw new TransportException("Invalid credentials for '" . $this->fileUrl . "', aborting.", $httpStatus); } - $this->io->overwriteError(''); - if ($warning) { - $this->io->writeError(' '.$warning.''); - } $this->io->writeError(' Authentication required ('.parse_url($this->fileUrl, PHP_URL_HOST).'):'); $username = $this->io->ask(' Username: '); $password = $this->io->askAndHideAnswer(' Password: '); @@ -1090,4 +1086,24 @@ class RemoteFilesystem return count($pathParts) >= 4 && $pathParts[3] == 'downloads'; } + + public static function outputWarnings(IOInterface $io, $url, $data) + { + foreach (array('warning', 'info') as $type) { + if (empty($data[$type])) { + continue; + } + + if (!empty($data[$type . '-versions'])) { + $versionParser = new VersionParser(); + $constraint = $versionParser->parseConstraints($data[$type . '-versions']); + $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion())); + if (!$constraint->matches($composer)) { + continue; + } + } + + $io->writeError('<'.$type.'>'.ucfirst($type).' from '.$url.': '.$data[$type].''); + } + } }