X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Ffilesystem%2FLockHandler.php;h=8e0eb741213b2e1c03bd62fbf86ea1450e0ad692;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=67e6f8f522c1c2a96402524d18f67fcfd62cfcce;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/filesystem/LockHandler.php b/vendor/symfony/filesystem/LockHandler.php index 67e6f8f52..8e0eb7412 100644 --- a/vendor/symfony/filesystem/LockHandler.php +++ b/vendor/symfony/filesystem/LockHandler.php @@ -12,6 +12,10 @@ namespace Symfony\Component\Filesystem; use Symfony\Component\Filesystem\Exception\IOException; +use Symfony\Component\Lock\Store\FlockStore; +use Symfony\Component\Lock\Store\SemaphoreStore; + +@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use %s or %s instead.', LockHandler::class, SemaphoreStore::class, FlockStore::class), E_USER_DEPRECATED); /** * LockHandler class provides a simple abstraction to lock anything by means of @@ -25,6 +29,8 @@ use Symfony\Component\Filesystem\Exception\IOException; * @author Grégoire Pineau * @author Romain Neutron * @author Nicolas Grekas + * + * @deprecated since version 3.4, to be removed in 4.0. Use Symfony\Component\Lock\Store\SemaphoreStore or Symfony\Component\Lock\Store\FlockStore instead. */ class LockHandler { @@ -56,7 +62,7 @@ class LockHandler /** * Lock the resource. * - * @param bool $blocking wait until the lock is released + * @param bool $blocking Wait until the lock is released * * @return bool Returns true if the lock was acquired, false otherwise * @@ -68,22 +74,25 @@ class LockHandler return true; } + $error = null; + // Silence error reporting - set_error_handler(function () {}); + set_error_handler(function ($errno, $msg) use (&$error) { + $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')) { + chmod($this->file, 0666); + } 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(); if (!$this->handle) { - $error = error_get_last(); - throw new IOException($error['message'], 0, null, $this->file); + throw new IOException($error, 0, null, $this->file); } // On Windows, even if PHP doc says the contrary, LOCK_NB works, see