Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] fix semaphore unguarding #41289

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3164,15 +3164,8 @@
<file src="lib/private/Preview/Generator.php">
<InvalidArgument>
<code>$maxPreviewImage</code>
<code>$semId</code>
<code>IPreview::EVENT</code>
</InvalidArgument>
<InvalidReturnStatement>
<code>$sem</code>
</InvalidReturnStatement>
<InvalidReturnType>
<code>false|resource</code>
</InvalidReturnType>
<MismatchingDocblockParamType>
<code>ISimpleFile</code>
</MismatchingDocblockParamType>
Expand Down
8 changes: 4 additions & 4 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function generatePreviews(File $file, array $specifications, $mimeType =
*
* @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')) {
Expand All @@ -246,11 +246,11 @@ public static function guardWithSemaphore(int $semId, int $concurrency) {
/**
* 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);
Expand Down
Loading