diff options
| author | 2021-01-02 21:20:19 +0100 | |
|---|---|---|
| committer | 2021-01-02 21:20:19 +0100 | |
| commit | 9c6682e7edf8cbad828088cbeeef66c7ecefdd9a (patch) | |
| tree | c8c8a6ba34d49d22497a14ddaf18ae97d8cd5bb1 /app/actualize_script.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/actualize_script.php')
| -rwxr-xr-x | app/actualize_script.php | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/app/actualize_script.php b/app/actualize_script.php index 18b7f99f8..8bbc45e41 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -32,39 +32,42 @@ $_SERVER['HTTP_HOST'] = ''; $app = new FreshRSS(); -$system_conf = Minz_Configuration::get('system'); -$system_conf->auth_type = 'none'; // avoid necessity to be logged in (not saved!) -define('SIMPLEPIE_SYSLOG_ENABLED', $system_conf->simplepie_syslog_enabled); +FreshRSS_Context::initSystem(); +FreshRSS_Context::$system_conf->auth_type = 'none'; // avoid necessity to be logged in (not saved!) +define('SIMPLEPIE_SYSLOG_ENABLED', FreshRSS_Context::$system_conf->simplepie_syslog_enabled); notice('FreshRSS starting feeds actualization at ' . $begin_date->format('c')); // make sure the PHP setup of the CLI environment is compatible with FreshRSS as well -performRequirementCheck($system_conf->db['type']); +performRequirementCheck(FreshRSS_Context::$system_conf->db['type']); // Create the list of users to actualize. // Users are processed in a random order but always start with default user $users = listUsers(); shuffle($users); -if ($system_conf->default_user !== '') { - array_unshift($users, $system_conf->default_user); +if (FreshRSS_Context::$system_conf->default_user !== '') { + array_unshift($users, FreshRSS_Context::$system_conf->default_user); $users = array_unique($users); } -$limits = $system_conf->limits; +$limits = FreshRSS_Context::$system_conf->limits; $min_last_activity = time() - $limits['max_inactivity']; foreach ($users as $user) { - if (!get_user_configuration($user)->enabled) { + FreshRSS_Context::initUser($user); + if (FreshRSS_Context::$user_conf == null) { + notice('Invalid user ' . $user); + continue; + } + if (!FreshRSS_Context::$user_conf->enabled) { notice('FreshRSS skip disabled user ' . $user); continue; } - if (($user !== $system_conf->default_user) && + if (($user !== FreshRSS_Context::$system_conf->default_user) && (FreshRSS_UserDAO::mtime($user) < $min_last_activity)) { notice('FreshRSS skip inactive user ' . $user); continue; } - Minz_Session::_param('currentUser', $user); - new Minz_ModelPdo($user); //TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init FreshRSS_Auth::giveAccess(); $app->init(); notice('FreshRSS actualize ' . $user . '...'); @@ -78,10 +81,6 @@ foreach ($users as $user) { } } - Minz_Session::_params([ - 'currentUser' => '_', - 'loginOk' => false, - ]); gc_collect_cycles(); } |
