1
0
Fork 0

Fix extension parsing to take the most usable data instead of just using 0 in case of parsing failure, fixes #5331, fixes #5264

pull/5347/head
Jordi Boggiano 2016-05-15 11:47:14 +01:00
parent 8f0324f51e
commit 0cca4d1a44
1 changed files with 8 additions and 2 deletions

View File

@ -94,19 +94,25 @@ class PlatformRepository extends ArrayRepository
if (in_array($name, array('standard', 'Core'))) { if (in_array($name, array('standard', 'Core'))) {
continue; continue;
} }
$extraDescription = null;
$reflExt = new \ReflectionExtension($name); $reflExt = new \ReflectionExtension($name);
try { try {
$prettyVersion = $reflExt->getVersion(); $prettyVersion = $reflExt->getVersion();
$version = $versionParser->normalize($prettyVersion); $version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) { } catch (\UnexpectedValueException $e) {
$extraDescription = ' (actual version: '.$prettyVersion.')';
if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
$prettyVersion = $match[1];
} else {
$prettyVersion = '0'; $prettyVersion = '0';
}
$version = $versionParser->normalize($prettyVersion); $version = $versionParser->normalize($prettyVersion);
} }
$packageName = $this->buildPackageName($name); $packageName = $this->buildPackageName($name);
$ext = new CompletePackage($packageName, $version, $prettyVersion); $ext = new CompletePackage($packageName, $version, $prettyVersion);
$ext->setDescription('The '.$name.' PHP extension'); $ext->setDescription('The '.$name.' PHP extension' . $extraDescription);
$this->addPackage($ext); $this->addPackage($ext);
} }