From 9c6682e7edf8cbad828088cbeeef66c7ecefdd9a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 2 Jan 2021 21:20:19 +0100 Subject: 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 --- cli/reconfigure.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'cli/reconfigure.php') diff --git a/cli/reconfigure.php b/cli/reconfigure.php index 45e913d76..7495fc367 100755 --- a/cli/reconfigure.php +++ b/cli/reconfigure.php @@ -37,14 +37,13 @@ if (!validateOptions($argv, array_merge($params, $dBparams))) { fwrite(STDERR, 'Reconfiguring FreshRSS…' . "\n"); -$config = Minz_Configuration::get('system'); foreach ($params as $param) { $param = rtrim($param, ':'); if (isset($options[$param])) { - $config->$param = $options[$param] === false ? true : $options[$param]; + FreshRSS_Context::$system_conf->$param = $options[$param] === false ? true : $options[$param]; } } -$db = $config->db; +$db = FreshRSS_Context::$system_conf->db; foreach ($dBparams as $dBparam) { $dBparam = rtrim($dBparam, ':'); if (isset($options[$dBparam])) { @@ -52,17 +51,19 @@ foreach ($dBparams as $dBparam) { $db[$param] = $options[$dBparam]; } } -$config->db = $db; +FreshRSS_Context::$system_conf->db = $db; -if (!FreshRSS_user_Controller::checkUsername($config->default_user)) { - fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $config->default_user); +if (!FreshRSS_user_Controller::checkUsername(FreshRSS_Context::$system_conf->default_user)) { + fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . + FreshRSS_Context::$system_conf->default_user); } -if (isset($config->auth_type) && !in_array($config->auth_type, array('form', 'http_auth', 'none'))) { +if (isset(FreshRSS_Context::$system_conf->auth_type) && + !in_array(FreshRSS_Context::$system_conf->auth_type, array('form', 'http_auth', 'none'))) { fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' - . $config->auth_type); + . FreshRSS_Context::$system_conf->auth_type); } -$config->save(); +FreshRSS_Context::$system_conf->save(); done(); -- cgit v1.2.3