From 0cca4d1a449527fc0e598fd6519b3a808b1598e2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 15 May 2016 11:47:14 +0100 Subject: [PATCH 1/2] Fix extension parsing to take the most usable data instead of just using 0 in case of parsing failure, fixes #5331, fixes #5264 --- src/Composer/Repository/PlatformRepository.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index d5e7e583c..f414ef409 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -94,19 +94,25 @@ class PlatformRepository extends ArrayRepository if (in_array($name, array('standard', 'Core'))) { continue; } + $extraDescription = null; $reflExt = new \ReflectionExtension($name); try { $prettyVersion = $reflExt->getVersion(); $version = $versionParser->normalize($prettyVersion); } catch (\UnexpectedValueException $e) { - $prettyVersion = '0'; + $extraDescription = ' (actual version: '.$prettyVersion.')'; + if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) { + $prettyVersion = $match[1]; + } else { + $prettyVersion = '0'; + } $version = $versionParser->normalize($prettyVersion); } $packageName = $this->buildPackageName($name); $ext = new CompletePackage($packageName, $version, $prettyVersion); - $ext->setDescription('The '.$name.' PHP extension'); + $ext->setDescription('The '.$name.' PHP extension' . $extraDescription); $this->addPackage($ext); } From 206c3c52e02ad75abb751faf1d116e92a0866625 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 15 May 2016 12:04:41 +0100 Subject: [PATCH 2/2] Remove the error handler at the end of a run, fixes #5340 --- src/Composer/Console/Application.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 9c153542e..2523ed4a7 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -228,9 +228,12 @@ class Application extends BaseApplication $io->writeError('Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MB), time: '.round(microtime(true) - $startTime, 2).'s'); } + restore_error_handler(); + return $result; } catch (\Exception $e) { $this->hintCommonErrors($e); + restore_error_handler(); throw $e; } }