Merge pull request #41263 from nextcloud/enh/noid/fix-semaphore-guarding

This commit is contained in:
Simon L 2023-11-03 16:46:45 +01:00 committed by GitHub
commit 86e9fcab21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View file

@ -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>

View file

@ -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);