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 --- p/api/pshb.php | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'p/api/pshb.php') diff --git a/p/api/pshb.php b/p/api/pshb.php index 1e07c0f80..c2436d0ff 100644 --- a/p/api/pshb.php +++ b/p/api/pshb.php @@ -9,9 +9,8 @@ header('X-Content-Type-Options: nosniff'); $ORIGINAL_INPUT = file_get_contents('php://input', false, null, 0, MAX_PAYLOAD); -Minz_Configuration::register('system', DATA_PATH . '/config.php', FRESHRSS_PATH . '/config.default.php'); -$system_conf = Minz_Configuration::get('system'); -$system_conf->auth_type = 'none'; // avoid necessity to be logged in (not saved!) +FreshRSS_Context::initSystem(); +FreshRSS_Context::$system_conf->auth_type = 'none'; // avoid necessity to be logged in (not saved!) //Minz_Log::debug(print_r(array('_SERVER' => $_SERVER, '_GET' => $_GET, '_POST' => $_POST, 'INPUT' => $ORIGINAL_INPUT), true), PSHB_LOG); @@ -58,10 +57,6 @@ if (empty($users)) { $url = base64url_decode($canonical64); Minz_Log::warning('Warning: Nobody subscribes to this feed anymore!: ' . $url, PSHB_LOG); unlink('../../keys/' . $key . '.txt'); - Minz_Configuration::register('system', - DATA_PATH . '/config.php', - FRESHRSS_PATH . '/config.default.php'); - FreshRSS_Context::$system_conf = Minz_Configuration::get('system'); $feed = new FreshRSS_Feed($url); $feed->pubSubHubbubSubscribe(false); unlink('!hub.json'); @@ -129,12 +124,7 @@ foreach ($users as $userFilename) { } try { - Minz_Session::_param('currentUser', $username); - Minz_Configuration::register('user', - join_path(USERS_PATH, $username, 'config.php'), - join_path(FRESHRSS_PATH, 'config-user.default.php')); - new Minz_ModelPdo($username); //TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init - FreshRSS_Context::init(); + FreshRSS_Context::initUser($username); if (FreshRSS_Context::$user_conf != null) { Minz_ExtensionManager::enableByList(FreshRSS_Context::$user_conf->extensions_enabled); Minz_Translate::reset(FreshRSS_Context::$user_conf->language); -- cgit v1.2.3