From 0e768fadfc473d58f13a34a972c755a583de2e0a Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 3 Nov 2023 11:47:12 +0100 Subject: fix semaphore unguarding Signed-off-by: Simon L --- build/psalm-baseline.xml | 7 ------- lib/private/Preview/Generator.php | 8 ++++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 23021eb80b8..fae69bf6fa0 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -3164,15 +3164,8 @@ $maxPreviewImage - $semId IPreview::EVENT - - $sem - - - false|resource - ISimpleFile diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index d75d9c84cd2..c83cdb96e27 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -227,7 +227,7 @@ class Generator { * * @param int $semId * @param int $concurrency - * @return false|resource the semaphore on success or false on failure + * @return false|\SysvSemaphore the semaphore on success or false on failure */ public static function guardWithSemaphore(int $semId, int $concurrency) { if (!extension_loaded('sysvsem')) { @@ -246,11 +246,11 @@ class Generator { /** * Releases the semaphore acquired from {@see Generator::guardWithSemaphore()}. * - * @param resource|bool $semId the semaphore identifier returned by guardWithSemaphore + * @param false|\SysvSemaphore $semId the semaphore identifier returned by guardWithSemaphore * @return bool */ - public static function unguardWithSemaphore($semId): bool { - if (!is_resource($semId) || !extension_loaded('sysvsem')) { + public static function unguardWithSemaphore(false|\SysvSemaphore $semId): bool { + if ($semId === false || !($semId instanceof \SysvSemaphore)) { return false; } return sem_release($semId); -- cgit v1.2.3