Skip to content

Commit 608cf7f

Browse files
bug #27903 [Lock] fix lock file permissions (fritzmg)
This PR was squashed before being merged into the 3.4 branch (closes #27903). Discussion ---------- [Lock] fix lock file permissions | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | see discussion below | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See [this comment](#27668 (comment)). Since we are using `r+` now to fix an issue on Solaris, we also need to change the file permissions when the lock file is created for the first time. Otherwise ```php fopen($fileName, 'r+') ``` will fail due to the file permissions and while ```php fopen($fileName, 'r') ``` will work, the subsequent locking will again fail on Solaris. Changing the file permissions to `0666` fixes this issue. __However__ any lock file that was generated _prior_ to this change will still cause issues and would need to be manually deleted. Usually the default `sys_get_temp_dir()` location is used for the lock files and _usually_ these files are purged periodically, so it probably won't matter that much. But it still might cause some confusion since it will not be transparent, why the file lock failed on Solaris systems. Commits ------- 23481a1 [Lock] fix lock file permissions
2 parents 55ddaee + 23481a1 commit 608cf7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Lock/Store/FlockStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private function lock(Key $key, $blocking)
8181
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
8282
if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
8383
if ($handle = fopen($fileName, 'x')) {
84-
chmod($fileName, 0444);
84+
chmod($fileName, 0644);
8585
} elseif (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
8686
usleep(100); // Give some time for chmod() to complete
8787
$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r');

0 commit comments

Comments
 (0)