Skip to content

Commit

Permalink
[BUGFIX] Resolve type issues in SemaphoreLockStrategy
Browse files Browse the repository at this point in the history
ftok() doesn't return false, but -1 on error.

The $resource property may be null to indicate no lock
is active, so allow that.

Resolves: #97644
Releases: main, 11.5
Change-Id: I88eb20b2399c119390c7e6c34c985a87706db4d3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74654
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
Crell authored and bmack committed May 20, 2022
1 parent 7c3af95 commit d111cc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions Build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -950,16 +950,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Classes/Localization/LanguageService.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php

-
message: "#^Strict comparison using \\=\\=\\= between int and false will always evaluate to false\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php

-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SemaphoreLockStrategy implements LockingStrategyInterface
protected $id;

/**
* @var resource|\SysvSemaphore Semaphore Resource used for this lock
* @var resource|\SysvSemaphore|null Semaphore Resource used for this lock
*/
protected $resource;

Expand Down Expand Up @@ -83,7 +83,7 @@ public function __construct($subject)
$this->filePath = $path . 'sem_' . md5((string)$subject);
touch($this->filePath);
$this->id = ftok($this->filePath, 'A');
if ($this->id === false) {
if ($this->id === -1) {
throw new LockCreateException('Cannot create key for semaphore using path ' . $this->filePath, 1396278734);
}
}
Expand Down

0 comments on commit d111cc5

Please sign in to comment.