Skip to content

Commit 52b3c9c

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: (33 commits) do not pass a boolean to the constructor of the Dotenv class [Notifier] Fix low-deps tests Deprecate Composer 1 [Filesystem] Add third argument `$lockFile` to `Filesystem::appendToFile()` [TwigBundle] fix auto-enabling assets/expression/routing/yaml/workflow extensions [PhpUnitBridge] fix symlink to bridge in docker by making its path relative [Dotenv] Duplicate $_SERVER values in $_ENV if they don't exist Fix markup [Notifier] Add Expo bridge Add polish translations (#43725) Rename translation:update to translation:extract [String] Add PLURAL_MAP "zombies" -- fix #43789 Added support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller. [Validator] Update validators.bs.xlf Cache voters that will always abstain [Messenger] Fix `TraceableMessageBus` implementation so it can compute caller even when used within a callback [Validator] Add the missing translations for Russian (ru) [Validator] Added missing translations for Latvian (lv) [Validator] Added missing translations [Validator] Add missing translations for Vietnamese (VI) ...
2 parents 3e9a18c + 731f917 commit 52b3c9c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Add `Path` class
8+
* Add `$lock` argument to `Filesystem::appendToFile()`
89

910
5.0.0
1011
-----

Filesystem.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,11 @@ public function dumpFile(string $filename, $content)
665665
* Appends content to an existing file.
666666
*
667667
* @param string|resource $content The content to append
668+
* @param bool $lock Whether the file should be locked when writing to it
668669
*
669670
* @throws IOException If the file is not writable
670671
*/
671-
public function appendToFile(string $filename, $content)
672+
public function appendToFile(string $filename, $content/*, bool $lock = false*/)
672673
{
673674
if (\is_array($content)) {
674675
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
@@ -680,7 +681,9 @@ public function appendToFile(string $filename, $content)
680681
$this->mkdir($dir);
681682
}
682683

683-
if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) {
684+
$lock = \func_num_args() > 2 && func_get_arg(2);
685+
686+
if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) {
684687
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
685688
}
686689
}

0 commit comments

Comments
 (0)