Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Filesystem : can lock file on append of content #49262

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Illuminate/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,12 @@ public function prepend($path, $data)
*
* @param string $path
* @param string $data
* @param bool $lock
* @return int
*/
public function append($path, $data)
public function append($path, $data, $lock = false)
{
return file_put_contents($path, $data, FILE_APPEND);
return file_put_contents($path, $data, FILE_APPEND | ($lock ? LOCK_EX : 0));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Facades/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @method static void replace(string $path, string $content, int|null $mode = null)
* @method static void replaceInFile(array|string $search, array|string $replace, string $path)
* @method static int prepend(string $path, string $data)
* @method static int append(string $path, string $data)
* @method static int append(string $path, string $data, bool $lock = false)
* @method static mixed chmod(string $path, int|null $mode = null)
* @method static bool delete(string|array $paths)
* @method static bool move(string $path, string $target)
Expand Down