From fe5ac24949a6a30a023f10a57375a7bf067a92d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 3 Nov 2022 11:53:51 +0100 Subject: [PATCH 1/2] Avoid a crash when a PHP extension has no version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/App/PlatformRepository.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/private/App/PlatformRepository.php b/lib/private/App/PlatformRepository.php index 94fac5260e155..3e7f0f3c5a5a2 100644 --- a/lib/private/App/PlatformRepository.php +++ b/lib/private/App/PlatformRepository.php @@ -48,7 +48,7 @@ protected function initialize() { $ext = new \ReflectionExtension($name); try { $prettyVersion = $ext->getVersion(); - $prettyVersion = $this->normalizeVersion($prettyVersion); + $prettyVersion = $this->normalizeVersion($prettyVersion ?? '0'); } catch (\UnexpectedValueException $e) { $prettyVersion = '0'; $prettyVersion = $this->normalizeVersion($prettyVersion); @@ -109,6 +109,9 @@ protected function initialize() { continue 2; } + if ($prettyVersion === null) { + continue; + } try { $prettyVersion = $this->normalizeVersion($prettyVersion); } catch (\UnexpectedValueException $e) { From 9d377a17515b5da16d256632e713d17b774b3189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 7 Nov 2022 10:01:53 +0100 Subject: [PATCH 2/2] Suppress false-positives from psalm, waiting for fix upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/App/PlatformRepository.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/App/PlatformRepository.php b/lib/private/App/PlatformRepository.php index 3e7f0f3c5a5a2..2bf1b61fefe77 100644 --- a/lib/private/App/PlatformRepository.php +++ b/lib/private/App/PlatformRepository.php @@ -48,6 +48,10 @@ protected function initialize() { $ext = new \ReflectionExtension($name); try { $prettyVersion = $ext->getVersion(); + /** @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';