From 36aa0122e15b6c5a4bf923467b63a577cac5a539 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 4 Apr 2023 10:23:26 +0200 Subject: Fix extensions in actualize_script (#5243) * Fix extension freshrss_user_maintenance in actualize_script Follow-up of https://github.com/FreshRSS/FreshRSS/pull/3440 The hook was called before registering all the extensions for the current user * PHPStan Level 6 for extensions And remove 5-year old legacy format of enabled extensions < FreshRSS 1.11.1 * Fix multiple bugs in extensions * Minor typing * Don't change signature of methods supposed to be overridden * PHPStan Level 9 and compatibility Intelliphense * Set as final the methods not supposed to be overriden --- app/actualize_script.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'app/actualize_script.php') diff --git a/app/actualize_script.php b/app/actualize_script.php index b4d57c4e3..4a38c13f7 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -18,6 +18,9 @@ $_SERVER['HTTP_HOST'] = ''; $app = new FreshRSS(); FreshRSS_Context::initSystem(); +if (FreshRSS_Context::$system_conf === null) { + throw new FreshRSS_Context_Exception('System configuration not initialised!'); +} 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); @@ -54,11 +57,6 @@ fclose($handle); register_shutdown_function(function () use ($mutexFile) { unlink($mutexFile); }); - -Minz_ExtensionManager::addHook('feed_before_actualize', function ($feed) use ($mutexFile) { - touch($mutexFile); - return $feed; -}); // notice('FreshRSS starting feeds actualization at ' . $begin_date->format('c')); @@ -99,11 +97,17 @@ foreach ($users as $user) { FreshRSS_Auth::giveAccess(); - Minz_ExtensionManager::callHook('freshrss_user_maintenance'); - + // NB: Extensions and hooks are reinitialised there $app->init(); + + Minz_ExtensionManager::addHook('feed_before_actualize', function ($feed) use ($mutexFile) { + touch($mutexFile); + return $feed; + }); + notice('FreshRSS actualize ' . $user . '…'); echo $user, ' '; //Buffered + Minz_ExtensionManager::callHook('freshrss_user_maintenance'); $app->run(); if (!invalidateHttpCache()) { -- cgit v1.2.3