diff options
| author | 2025-06-22 00:10:13 +0200 | |
|---|---|---|
| committer | 2025-06-22 00:10:13 +0200 | |
| commit | bea9ca12adf58896a95959c4a1fbb48f4bbc144b (patch) | |
| tree | 686e3e1bebe52dbefc34a6f7bae9250152fa8792 /app/Controllers/userController.php | |
| parent | 50887f191b12f198d3aa81858c98a2f019b9a4f1 (diff) | |
Restore user config from backup when it doesn't exist (#7682)
* Restore user config from backup when it doesn't exist
* Supress warnings
* Remove copied config if copy() fails
* `return false` after `unlink()`
* Performance
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers/userController.php')
| -rw-r--r-- | app/Controllers/userController.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 9eac0d8ce..35851fceb 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -16,7 +16,18 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController { } public static function userExists(string $username): bool { - return @file_exists(USERS_PATH . '/' . $username . '/config.php'); + $config_path = USERS_PATH . '/' . $username . '/config.php'; + if (@file_exists($config_path)) { + return true; + } elseif (@file_exists($config_path . '.bak.php')) { + Minz_Log::warning('Config for user “' . $username . '” not found. Attempting to restore from backup.', ADMIN_LOG); + if (!copy($config_path . '.bak.php', $config_path)) { + @unlink($config_path); + return false; + } + return @file_exists($config_path); + } + return false; } /** @param array<string,mixed> $userConfigUpdated */ |
