From a8bc49c996934b0c31da7506bb855c0becce802d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Benoist?= Date: Wed, 24 Jul 2019 14:45:25 +0200 Subject: [PATCH] Prevent concurrent writes Concurrent writes might lead to invalid JSON being saved in the cookie jar. --- src/Cookie/FileCookieJar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cookie/FileCookieJar.php b/src/Cookie/FileCookieJar.php index 9887c1d5..0de80909 100644 --- a/src/Cookie/FileCookieJar.php +++ b/src/Cookie/FileCookieJar.php @@ -56,7 +56,7 @@ class FileCookieJar extends CookieJar } $jsonStr = \GuzzleHttp\json_encode($json); - if (false === file_put_contents($filename, $jsonStr)) { + if (false === file_put_contents($filename, $jsonStr, LOCK_EX)) { throw new \RuntimeException("Unable to save file {$filename}"); } }