summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-11-03 16:46:45 +0100
committerGitHub <noreply@github.com>2023-11-03 16:46:45 +0100
commit86e9fcab21e8b4afc44f3b3597ac2f10e703fe1b (patch)
treee44d70eb4af92a92d21e7f743761bece12ddf737
parentfbd8f76e42bcde54b08880baf23d17170ee1d529 (diff)
parentb681cf735a29b6ae25e03813b2efe77e4fe25613 (diff)
downloadnextcloud-server-86e9fcab21e8b4afc44f3b3597ac2f10e703fe1b.tar.gz
nextcloud-server-86e9fcab21e8b4afc44f3b3597ac2f10e703fe1b.zip
Merge pull request #41263 from nextcloud/enh/noid/fix-semaphore-guarding
-rw-r--r--build/psalm-baseline.xml7
-rw-r--r--lib/private/Preview/Generator.php8
2 files changed, 4 insertions, 11 deletions
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 8a2c728ab5b..273c7ef4709 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -3075,14 +3075,7 @@
<file src="lib/private/Preview/Generator.php">
<InvalidArgument>
<code>$maxPreviewImage</code>
- <code>$semId</code>
</InvalidArgument>
- <InvalidReturnStatement>
- <code>$sem</code>
- </InvalidReturnStatement>
- <InvalidReturnType>
- <code>false|resource</code>
- </InvalidReturnType>
<LessSpecificReturnType>
<code>null|string</code>
</LessSpecificReturnType>
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 4a1270fa4a6..958f58e2a01 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -221,7 +221,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')) {
@@ -240,11 +240,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);