Fixes#9650
Writes the temporary config file with a checked full write followed by `fflush()` and `fsync()` before the atomic rename, so an unclean shutdown cannot leave `config.php` truncated to zero bytes. The backup is now only replaced when the current config file is non-empty, preserving the last known-good backup if a previous save was interrupted.
Adds regression tests covering a normal save (previous config backed up) and a save when the current config file is empty (existing backup preserved).
* Make configuration saves crash-safe
* Simplify comments
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>