Merge pull request #35005 from nextcloud/backport/34937/stable24

[stable24] Avoid a crash when a PHP extension has no version
This commit is contained in:
Simon L 2022-11-07 17:46:20 +01:00 committed by GitHub
commit 29e31f4da8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,7 +48,11 @@ class PlatformRepository {
$ext = new \ReflectionExtension($name);
try {
$prettyVersion = $ext->getVersion();
$prettyVersion = $this->normalizeVersion($prettyVersion);
/** @psalm-suppress TypeDoesNotContainNull
* @psalm-suppress RedundantCondition
* TODO Remove these annotations once psalm fixes the method signature ( https://github.com/vimeo/psalm/pull/8655 )
*/
$prettyVersion = $this->normalizeVersion($prettyVersion ?? '0');
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$prettyVersion = $this->normalizeVersion($prettyVersion);
@ -109,6 +113,9 @@ class PlatformRepository {
continue 2;
}
if ($prettyVersion === null) {
continue;
}
try {
$prettyVersion = $this->normalizeVersion($prettyVersion);
} catch (\UnexpectedValueException $e) {