From f9f92dc9d8a3d89597c80d6a0892823357181e3c Mon Sep 17 00:00:00 2001 From: Lauris Binde Date: Wed, 11 Jan 2017 09:25:25 +0200 Subject: [PATCH 1/7] Fix Xdebug warning Composer incorrectly shows Xdebug warning, even if extension is not loaded, but COMPOSER_ALLOW_XDEBUG is present. --- src/Composer/Console/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 076e88419..892c0af9d 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -166,7 +166,7 @@ class Application extends BaseApplication $io->writeError('Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.'); } - if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN') || getenv('COMPOSER_ALLOW_XDEBUG')) { + if (extension_loaded('xdebug') && (!getenv('COMPOSER_DISABLE_XDEBUG_WARN') || getenv('COMPOSER_ALLOW_XDEBUG'))) { $io->writeError('You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug'); } From f29a302391bee67e64bbe71184fbeeca1bdd432b Mon Sep 17 00:00:00 2001 From: Ed Reel Date: Fri, 20 Jan 2017 19:53:41 -0600 Subject: [PATCH 2/7] Return 1 if composer.json exists, but the package doesn't. --- src/Composer/Command/ShowCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 0b9dc7616..12981fb47 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -173,7 +173,7 @@ EOT } $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json'); - return; + return 1; } } else { $versions = array($package->getPrettyVersion() => $package->getVersion()); From 0ea93df252d53d62a8a48ea190f69d0967ab4f18 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 11 Jan 2017 13:37:13 +0100 Subject: [PATCH 3/7] Fixed no lock file was written when setting writeLock to true and executeOperations to false --- src/Composer/Installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index ec8157456..9f6fa5d04 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -605,7 +605,7 @@ class Installer $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation); } - if ($this->executeOperations) { + if ($this->executeOperations || $this->writeLock) { $localRepo->write(); } } From e4840ee41352944ad789e1d08ce3f01b2f4e9948 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 22 Jan 2017 18:26:49 +0100 Subject: [PATCH 4/7] Add a COMPOSER_BINARY env var so that chdir does not affect @composer script resolvability, fixes #6080 --- bin/composer | 2 ++ src/Composer/EventDispatcher/EventDispatcher.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/composer b/bin/composer index 823f87a4b..88566e170 100755 --- a/bin/composer +++ b/bin/composer @@ -48,6 +48,8 @@ if (function_exists('ini_set')) { unset($memoryInBytes, $memoryLimit); } +putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0])); + // run the command application $application = new Application(); $application->run(null, $output); diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index e6cc378a0..fdb008668 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -180,7 +180,7 @@ class EventDispatcher if (!$phpPath) { throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName); } - $exec = $phpPath . ' ' . realpath($_SERVER['argv'][0]) . substr($callable, 9); + $exec = ProcessExecutor::escape($phpPath) . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9); if (0 !== ($exitCode = $this->process->execute($exec))) { $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName())); From 9a26a9e8f82d79e9834605610a8d6cbd4aba6d34 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 22 Jan 2017 18:44:15 +0100 Subject: [PATCH 5/7] Make sure alias packages installed with create-project end up with the correct branch checked out, fixes #6082 --- src/Composer/Command/CreateProjectCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 796dbdeb9..4e443d337 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -23,6 +23,7 @@ use Composer\Package\BasePackage; use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Operation\InstallOperation; use Composer\Package\Version\VersionSelector; +use Composer\Package\AliasPackage; use Composer\Repository\RepositoryFactory; use Composer\Repository\CompositeRepository; use Composer\Repository\PlatformRepository; @@ -330,6 +331,10 @@ EOT $io->writeError('Plugins have been disabled.'); } + if ($package instanceof AliasPackage) { + $package = $package->getAliasOf(); + } + if (0 === strpos($package->getPrettyVersion(), 'dev-') && in_array($package->getSourceType(), array('git', 'hg'))) { $package->setSourceReference(substr($package->getPrettyVersion(), 4)); } From 7aa7c3ced3e34cd9067963144dd02108bc1a936f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 22 Jan 2017 19:03:22 +0100 Subject: [PATCH 6/7] Forward composer memory_limit to child processes, fixes #6075 --- .../EventDispatcher/EventDispatcher.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index fdb008668..b74d34858 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -175,12 +175,7 @@ class EventDispatcher $args = $event->getArguments(); $flags = $event->getFlags(); if (substr($callable, 0, 10) === '@composer ') { - $finder = new PhpExecutableFinder(); - $phpPath = $finder->find(); - if (!$phpPath) { - throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName); - } - $exec = ProcessExecutor::escape($phpPath) . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9); + $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9); if (0 !== ($exitCode = $this->process->execute($exec))) { $this->io->writeError(sprintf('Script %s handling the %s event returned with error code '.$exitCode.'', $callable, $event->getName())); @@ -234,12 +229,7 @@ class EventDispatcher } if (substr($exec, 0, 5) === '@php ') { - $finder = new PhpExecutableFinder(); - $phpPath = $finder->find(); - if (!$phpPath) { - throw new \RuntimeException('Failed to locate PHP binary to execute "'.$exec.'"'); - } - $exec = $phpPath . ' ' . substr($exec, 5); + $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5); } if (0 !== ($exitCode = $this->process->execute($exec))) { @@ -259,6 +249,19 @@ class EventDispatcher return $return; } + protected function getPhpExecCommand() + { + $finder = new PhpExecutableFinder(); + $phpPath = $finder->find(); + if (!$phpPath) { + throw new \RuntimeException('Failed to locate PHP binary to execute '.$scriptName); + } + + $memoryFlag = ' -d memory_limit='.ini_get('memory_limit'); + + return ProcessExecutor::escape($phpPath) . $memoryFlag; + } + /** * @param string $className * @param string $methodName From 65a572731517767a4a021c5c20e3e79f579e5eb4 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 15 Jan 2017 13:37:03 +0100 Subject: [PATCH 7/7] Do not hide the warning implicitly Even if COMPOSER_ALLOW_XDEBUG is set, requires to also set COMPOSER_DISABLE_XDEBUG_WARN to hide the warning. This undoes commit c5dcedd. --- src/Composer/Console/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 892c0af9d..a2165ea76 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -166,7 +166,7 @@ class Application extends BaseApplication $io->writeError('Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.'); } - if (extension_loaded('xdebug') && (!getenv('COMPOSER_DISABLE_XDEBUG_WARN') || getenv('COMPOSER_ALLOW_XDEBUG'))) { + if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) { $io->writeError('You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug'); }