Skip to content

Commit

Permalink
Prevent concurrent writes
Browse files Browse the repository at this point in the history
Concurrent writes might lead to invalid JSON being saved in the cookie jar.
Hopefully fixes #1883 .
  • Loading branch information
greg0ire committed Jul 26, 2017
1 parent 9c1d1e2 commit 95f0cd5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Cookie/FileCookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function save($filename)
}
}

if (false === file_put_contents($filename, json_encode($json))) {
if (false === file_put_contents($filename, json_encode($json), LOCK_EX)) {
// @codeCoverageIgnoreStart
throw new \RuntimeException("Unable to save file {$filename}");
// @codeCoverageIgnoreEnd
Expand Down

0 comments on commit 95f0cd5

Please sign in to comment.