Repository navigation
Description
Describe the bug
Minz_Configuration::save() writes the configuration to a temporary file, copies the current file to a backup, and replaces the configuration file with rename():
FreshRSS/lib/Minz/Configuration.php
Lines 224 to 234 in 735c369
| $tmp_filename = $this->config_filename . '.tmp.php'; | |
| $back_filename = $this->config_filename . '.bak.php'; | |
| if (!file_put_contents($tmp_filename, | |
| "<?php\nreturn " . var_export($this->data, true) . ';', LOCK_EX)) { | |
| @unlink($tmp_filename); | |
| return false; | |
| } | |
| if (!copy($this->config_filename, $back_filename)) { | |
| @unlink($tmp_filename); |
The result of the rename() is discarded, and the method returns true whatever happened.
When the replacement fails, the configuration file still holds the previous values and the temporary file stays next to it, but the caller is told that the configuration was saved.
To Reproduce
Run this script from the root of the repository:
<?php
require 'constants.php';
require LIB_PATH . '/lib_rss.php';
$dir = sys_get_temp_dir() . '/freshrss-save';
@mkdir($dir);
file_put_contents($dir . '/config.php', "<?php\nreturn ['title' => 'FreshRSS'];\n");
// A save that was interrupted leaves its temporary and backup files behind.
file_put_contents($dir . '/config.php.tmp.php', '');
file_put_contents($dir . '/config.php.bak.php', '');
chmod($dir, 0555);
Minz_Configuration::register('test', $dir . '/config.php');
$conf = Minz_Configuration::get('test');
var_dump($conf->save()); // true
var_dump(file_get_contents($dir . '/config.php')); // the previous valuesThe directory is not writable, so the configuration file cannot be replaced, yet save() reports success.
Expected behavior
save() returns false when the configuration file was not replaced, and removes its temporary file, as it already does when the temporary file cannot be written or the backup cannot be copied.
FreshRSS version
1.30.5-dev (edge, 735c369)
System information
- Database version: any
- PHP version: 8.5.12
- Installation type: git
- Web server type: any
- Device: desktop
- OS: Linux
Additional context
Any reason the replacement fails ends here: an unwritable data directory, a file replaced by a directory, or a failure from the filesystem.
app/Controllers/userController.php checks the return value in three places (115, 641 and 802). Every other caller ignores it, so a failed save is displayed as “saved” as well.
Activity
Alkarex commentedon Nov 18, 2026
Thanks for the PR! You are welcome to just submit a PR without previously filing an issue