diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 65c5f5f553a7..1a700a93a8ce 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -379,7 +379,11 @@ private function checkVersion($config) private function getCurlVersion() { - if (function_exists('curl_version')) { + if (extension_loaded('curl')) { + if (!HttpDownloader::isCurlEnabled()) { + return 'disabled via disable_functions, using php streams fallback, which reduces performance'; + } + $version = curl_version(); return ''.$version['version'].' '. diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index 5f4b60ca7484..b6b21cdaa8f0 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -67,8 +67,7 @@ public function __construct(IOInterface $io, Config $config, array $options = ar $this->options = array_replace_recursive($this->options, $options); $this->config = $config; - // TODO enable curl only on 5.6+ if older versions cause any problem - if (extension_loaded('curl')) { + if (self::isCurlEnabled()) { $this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls); } @@ -423,4 +422,9 @@ private function canUseCurl(array $job) return true; } + + public static function isCurlEnabled() + { + return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init'); + } }