From 0e584aa9808c82d72bb7e3d54fccd70865951783 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Tue, 2 Feb 2016 10:45:57 +0100 Subject: [PATCH] resolve issue --- src/Composer/Installer.php | 1 + .../installer/github-issues-4795.test | 47 +++++++++++++++++++ .../installer/update-refs-issue-4795.test | 33 ------------- 3 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 tests/Composer/Test/Fixtures/installer/github-issues-4795.test delete mode 100644 tests/Composer/Test/Fixtures/installer/update-refs-issue-4795.test diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index f59eac7d3..adc2dc67b 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1199,6 +1199,7 @@ class Installer foreach ($requirePackages as $requirePackage) { if (isset($skipPackages[$requirePackage->getName()])) { + $this->io->writeError('Dependency "' . $requirePackage->getName() . '" is also a root requirement, but is not explicitly whitelisted. Ignoring.'); continue; } $packageQueue->enqueue($requirePackage); diff --git a/tests/Composer/Test/Fixtures/installer/github-issues-4795.test b/tests/Composer/Test/Fixtures/installer/github-issues-4795.test new file mode 100644 index 000000000..cf0a3ae6a --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/github-issues-4795.test @@ -0,0 +1,47 @@ +--TEST-- + +See Github issue #4795 ( github.com/composer/composer/issues/4795 ). + +Composer\Installer::whitelistUpdateDependencies intentionally ignores root requirements even if said package is also a +dependency of one the requirements that is whitelisted for update. + +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "a", "version": "1.0.0" }, + { "name": "a", "version": "1.1.0" }, + { "name": "b", "version": "1.0.0", "require": { "a": "~1.0" } }, + { "name": "b", "version": "1.1.0", "require": { "a": "~1.1" } }, + { "name": "c", "version": "1.0.0", "require": { "a": "~1.0" } } + ] + } + ], + "require": { + "a": "~1.0", + "b": "~1.0", + "c": "~1.0" + } +} + +--INSTALLED-- +[ + { "name": "a", "version": "1.0.0" }, + { "name": "b", "version": "1.0.0", "require": { "a": "~1.0" } }, + { "name": "c", "version": "1.0.0", "require": { "a": "~1.0" } } +] + +--RUN-- +update B --with-dependencies + +--EXPECT-OUTPUT-- +Dependency "a" is also a root requirement, but is not explicitly whitelisted. Ignoring. +Loading composer repositories with package information +Updating dependencies (including require-dev) +Nothing to install or update +Writing lock file +Generating autoload files + +--EXPECT-- diff --git a/tests/Composer/Test/Fixtures/installer/update-refs-issue-4795.test b/tests/Composer/Test/Fixtures/installer/update-refs-issue-4795.test deleted file mode 100644 index a359303bb..000000000 --- a/tests/Composer/Test/Fixtures/installer/update-refs-issue-4795.test +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Refs issue #4795 ---COMPOSER-- -{ - "repositories": [ - { - "type": "package", - "package": [ - { "name": "A", "version": "1.0.0" }, - { "name": "A", "version": "1.1.0" }, - { "name": "B", "version": "1.0.0", "require": { "A": "~1.0" } }, - { "name": "B", "version": "1.1.0", "require": { "A": "~1.1" } }, - { "name": "C", "version": "1.0.0", "require": { "A": "~1.0" } } - ] - } - ], - "require": { - "A": "~1.0", - "B": "~1.0", - "C": "~1.0" - } -} ---INSTALLED-- -[ - { "name": "A", "version": "1.0.0" }, - { "name": "B", "version": "1.0.0", "require": { "A": "~1.0" } }, - { "name": "C", "version": "1.0.0", "require": { "A": "~1.0" } } -] ---RUN-- -update B --with-dependencies ---EXPECT-- -Updating A (1.0.0) to A (1.1.0) -Updating B (1.0.0) to B (1.1.0)