Avoid file_put_contents() when overwriting files

this fixes many cases of corruption during disk-full situations - file_put_contents() would write an empty file, destroying the original data.
fixes #3152
This commit is contained in:
Dylan K. Taylor
2021-12-05 00:26:48 +00:00
parent 8e8cee45b8
commit 8e37f86480
5 changed files with 63 additions and 6 deletions

View File

@ -33,7 +33,6 @@ use function date;
use function explode;
use function file_exists;
use function file_get_contents;
use function file_put_contents;
use function implode;
use function is_array;
use function is_bool;
@ -228,7 +227,7 @@ class Config{
throw new AssumptionFailedError("Config type is unknown, has not been set or not detected");
}
file_put_contents($this->file, $content);
Filesystem::safeFilePutContents($this->file, $content);
$this->changed = false;
}