Skip to content

Commit

Permalink
Merge branch '5.4' into 6.0
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
xabbuh committed Oct 29, 2021
2 parents 3e9a18c + 731f917 commit 52b3c9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
---

* Add `Path` class
* Add `$lock` argument to `Filesystem::appendToFile()`

5.0.0
-----
Expand Down
7 changes: 5 additions & 2 deletions Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,11 @@ public function dumpFile(string $filename, $content)
* Appends content to an existing file.
*
* @param string|resource $content The content to append
* @param bool $lock Whether the file should be locked when writing to it
*
* @throws IOException If the file is not writable
*/
public function appendToFile(string $filename, $content)
public function appendToFile(string $filename, $content/*, bool $lock = false*/)
{
if (\is_array($content)) {
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
Expand All @@ -680,7 +681,9 @@ public function appendToFile(string $filename, $content)
$this->mkdir($dir);
}

if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) {
$lock = \func_num_args() > 2 && func_get_arg(2);

if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) {
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
}
}
Expand Down

0 comments on commit 52b3c9c

Please sign in to comment.