Merge pull request #41290 from nextcloud/backport/41263/stable26

[stable26] fix semaphore unguarding
This commit is contained in:
Simon L 2024-01-15 17:37:18 +01:00 committed by GitHub
commit 3d6b97cb38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View file

@ -1159,7 +1159,6 @@
</InvalidPropertyAssignmentValue>
<InvalidScalarArgument occurrences="1">
<code>0</code>
<code>0</code>
</InvalidScalarArgument>
</file>
<file src="apps/updatenotification/lib/Notification/Notifier.php">
@ -1517,7 +1516,6 @@
<file src="core/routes.php">
<InvalidScope occurrences="2">
<code>$this</code>
<code>$this</code>
</InvalidScope>
</file>
<file src="core/templates/layout.public.php">
@ -2173,7 +2171,6 @@
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>string</code>
<code>string</code>
</InvalidReturnType>
</file>
<file src="lib/private/Files/Node/Folder.php">
@ -2479,7 +2476,6 @@
<code>$lastChunkPos</code>
<code>$newUnencryptedSize</code>
<code>$size</code>
<code>$size</code>
<code>$sourceStorage-&gt;filemtime($sourceInternalPath)</code>
</InvalidScalarArgument>
</file>
@ -2537,7 +2533,6 @@
<code>null</code>
<code>null</code>
<code>null</code>
<code>null</code>
</NullableReturnStatement>
<RedundantCondition occurrences="1">
<code>is_resource($source)</code>
@ -2749,10 +2744,17 @@
</InvalidReturnStatement>
</file>
<file src="lib/private/Preview/Generator.php">
<InvalidArgument occurrences="2">
<InvalidArgument occurrences="3">
<code>$maxPreviewImage</code>
<code>$semId</code>
<code>IPreview::EVENT</code>
</InvalidArgument>
<InvalidReturnStatement occurrences="1">
<code>$sem</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>false|\SysvSemaphore</code>
</InvalidReturnType>
<MismatchingDocblockParamType occurrences="1">
<code>ISimpleFile</code>
</MismatchingDocblockParamType>

View file

@ -311,7 +311,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')) {
@ -330,11 +330,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);