[Lock] use 'r+' for fopen (fixes issue on Solaris)

This commit is contained in:
Fritz Michael Gschwantner 2018-06-21 09:40:59 +02:00 committed by Nicolas Grekas
parent ff0de67519
commit 9c9ae7d9c9

View File

@ -79,12 +79,12 @@ class FlockStore implements StoreInterface
// Silence error reporting
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
if (!$handle = fopen($fileName, 'r')) {
if (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
if ($handle = fopen($fileName, 'x')) {
chmod($fileName, 0444);
} elseif (!$handle = fopen($fileName, 'r')) {
} elseif (!$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r')) {
usleep(100); // Give some time for chmod() to complete
$handle = fopen($fileName, 'r');
$handle = fopen($fileName, 'r+') ?: fopen($fileName, 'r');
}
}
restore_error_handler();