diff options
| author | 2021-01-02 21:20:19 +0100 | |
|---|---|---|
| committer | 2021-01-02 21:20:19 +0100 | |
| commit | 9c6682e7edf8cbad828088cbeeef66c7ecefdd9a (patch) | |
| tree | c8c8a6ba34d49d22497a14ddaf18ae97d8cd5bb1 /app/FreshRSS.php | |
| parent | 7bc2cc5825547f5b5cf15005fda937e06065b45d (diff) | |
Avoid manual initialisations of system or user configuration (#3070)
* Avoid manual intialisations of system or user configuration
More consistent use of Context
* Simplify FreshRSS_Context::initUser
* Remove a few manual get_user_configuration
* A bit of debugging
* Fix context user init
* Fix install
* Fix concurrency
Concurrent requests could lead to bad race condition
* Fix actualize cron
Fix case when system i initialised several times
Diffstat (limited to 'app/FreshRSS.php')
| -rw-r--r-- | app/FreshRSS.php | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 5bf0011d0..fe55427c0 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -24,10 +24,12 @@ class FreshRSS extends Minz_FrontController { Minz_Session::init('FreshRSS'); } - // Register the configuration setter for the system configuration - $configuration_setter = new FreshRSS_ConfigurationSetter(); - $system_conf = Minz_Configuration::get('system'); - $system_conf->_configurationSetter($configuration_setter); + FreshRSS_Context::initSystem(); + if (FreshRSS_Context::$system_conf == null) { + $message = 'Error during context system init!'; + Minz_Error::error(500, [$message], false); + die($message); + } // Load list of extensions and enable the "system" ones. Minz_ExtensionManager::init(); @@ -35,26 +37,25 @@ class FreshRSS extends Minz_FrontController { // Auth has to be initialized before using currentUser session parameter // because it's this part which create this parameter. self::initAuth(); + if (FreshRSS_Context::$user_conf == null) { + FreshRSS_Context::initUser(); + } + if (FreshRSS_Context::$user_conf == null) { + $message = 'Error during context user init!'; + Minz_Error::error(500, [$message], false); + die($message); + } - // Then, register the user configuration and use the configuration setter - // created above. - $current_user = Minz_Session::param('currentUser', '_'); - Minz_Configuration::register('user', - join_path(USERS_PATH, $current_user, 'config.php'), - join_path(FRESHRSS_PATH, 'config-user.default.php'), - $configuration_setter); - - // Finish to initialize the other FreshRSS / Minz components. - FreshRSS_Context::init(); + // Complete initialization of the other FreshRSS / Minz components. self::initI18n(); self::loadNotifications(); // Enable extensions for the current (logged) user. - if (FreshRSS_Auth::hasAccess() || $system_conf->allow_anonymous) { + if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::$system_conf->allow_anonymous) { $ext_list = FreshRSS_Context::$user_conf->extensions_enabled; Minz_ExtensionManager::enableByList($ext_list); } - if ($system_conf->force_email_validation && !FreshRSS_Auth::hasAccess('admin')) { + if (FreshRSS_Context::$system_conf->force_email_validation && !FreshRSS_Auth::hasAccess('admin')) { self::checkEmailValidated(); } |
