mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Support symlinks when saving File
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
1. [](#new)
|
||||
* Added `Route::getBase()` method
|
||||
1. [](#improved)
|
||||
* Support symlinks when saving `File`
|
||||
1. [](#bugfix)
|
||||
* Fixed flex objects with integer keys not working [#2863](https://github.com/getgrav/grav/issues/2863)
|
||||
* Fixed user avatar creation for new `Flex Users` when using folder storage
|
||||
|
||||
@@ -279,11 +279,14 @@ class AbstractFile implements FileInterface
|
||||
$tmp = false;
|
||||
}
|
||||
} else {
|
||||
// Support for symlinks.
|
||||
$realpath = is_link($filepath) ? realpath($filepath) : $filepath;
|
||||
|
||||
// Create file with a temporary name and rename it to make the save action atomic.
|
||||
$tmp = $this->tempname($filepath);
|
||||
$tmp = $this->tempname($realpath);
|
||||
if (@file_put_contents($tmp, $data) === false) {
|
||||
$tmp = false;
|
||||
} elseif (@rename($tmp, $filepath) === false) {
|
||||
} elseif (@rename($tmp, $realpath) === false) {
|
||||
@unlink($tmp);
|
||||
$tmp = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user