From 04098153c8c4f3c2b2f329aa13f868bb5735032a Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Mon, 26 Nov 2018 12:32:31 +0100 Subject: [PATCH] Add support for running composer with phpdbg (#7798) --- bin/composer | 2 +- src/Composer/EventDispatcher/EventDispatcher.php | 7 ++++--- src/Composer/Util/StreamContextFactory.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/composer b/bin/composer index 7a80288b6..5e142662c 100755 --- a/bin/composer +++ b/bin/composer @@ -1,7 +1,7 @@ #!/usr/bin/env php find(); + $phpPath = $finder->find(false); if (!$phpPath) { throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath); } - + $phpArgs = $finder->findArguments(); + $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : ''; $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen')); $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions')); $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit')); - return ProcessExecutor::escape($phpPath) . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag; + return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag; } /** diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index 4e9b7f480..8dfd6624a 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -40,7 +40,7 @@ final class StreamContextFactory )); // Handle HTTP_PROXY/http_proxy on CLI only for security reasons - if (PHP_SAPI === 'cli' && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) { + if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) { $proxy = parse_url(!empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']); }