bug #27669 [Filesystem] fix file lock on SunOS (fritzmg)

This PR was merged into the 2.8 branch.

Discussion
----------

[Filesystem] fix file lock on SunOS

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

See https://github.com/symfony/symfony/pull/27668

Commits
-------

7adb641d7c fix file lock on SunOS
This commit is contained in:
Nicolas Grekas 2018-06-21 13:08:28 +02:00
commit f63579d360

View File

@ -75,12 +75,12 @@ class LockHandler
$error = $msg;
});
if (!$this->handle = fopen($this->file, 'r')) {
if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
if ($this->handle = fopen($this->file, 'x')) {
chmod($this->file, 0444);
} elseif (!$this->handle = fopen($this->file, 'r')) {
} elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
usleep(100); // Give some time for chmod() to complete
$this->handle = fopen($this->file, 'r');
$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
}
}
restore_error_handler();