From e5416ca4a9b964ebdd454bbb864cb21c6e56059a Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 7 Feb 2025 14:50:56 +0000 Subject: [PATCH 1/3] Deprecate providing LoggerInterface via addon strategies --- src/Core/Addon/Model/AddonLoader.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Core/Addon/Model/AddonLoader.php b/src/Core/Addon/Model/AddonLoader.php index 4686f7e74b..8ef27cb5a7 100644 --- a/src/Core/Addon/Model/AddonLoader.php +++ b/src/Core/Addon/Model/AddonLoader.php @@ -10,7 +10,9 @@ namespace Friendica\Core\Addon\Model; use Friendica\Core\Addon\Capability\ICanLoadAddons; use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException; use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\Logger\Factory\LoggerFactory; use Friendica\Util\Strings; +use Psr\Log\LoggerInterface; class AddonLoader implements ICanLoadAddons { @@ -48,6 +50,19 @@ class AddonLoader implements ICanLoadAddons throw new AddonInvalidConfigFileException('Error loading config file ' . $configFile); } + if ($configName === 'strategies') { + foreach ($config as $classname => $rule) { + if ($classname === LoggerInterface::class) { + @trigger_error(sprintf( + 'Providing a strategy for `%s` is deprecated since 2025.02, please provide an implementation for `%s` via `dependency.config.php` instead in %s addon.', + LoggerInterface::class, + LoggerFactory::class, + $addonName, + ), \E_USER_DEPRECATED); + } + } + } + $returnConfig = array_merge_recursive($returnConfig, $config); } From 1ea2df569e0ce1b0d6db996475691efbd8022999 Mon Sep 17 00:00:00 2001 From: Art4 Date: Fri, 7 Feb 2025 15:06:11 +0000 Subject: [PATCH 2/3] Deprecate strategies via addons --- src/Core/Addon/Model/AddonLoader.php | 10 ++++++++-- src/Core/Hooks/Util/StrategiesFileManager.php | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Core/Addon/Model/AddonLoader.php b/src/Core/Addon/Model/AddonLoader.php index 8ef27cb5a7..a608a66e3d 100644 --- a/src/Core/Addon/Model/AddonLoader.php +++ b/src/Core/Addon/Model/AddonLoader.php @@ -54,11 +54,17 @@ class AddonLoader implements ICanLoadAddons foreach ($config as $classname => $rule) { if ($classname === LoggerInterface::class) { @trigger_error(sprintf( - 'Providing a strategy for `%s` is deprecated since 2025.02, please provide an implementation for `%s` via `dependency.config.php` instead in %s addon.', - LoggerInterface::class, + 'Providing a strategy for `%s` is deprecated since 2025.02 and will stop working in 5 months, please provide an implementation for `%s` via `dependency.config.php` and remove the `strategies.config.php` file in the `%s` addon.', + $classname, LoggerFactory::class, $addonName, ), \E_USER_DEPRECATED); + } else { + @trigger_error(sprintf( + 'Providing strategies for `%s` via addons is deprecated since 2025.02 and will stop working in 5 months, please stop using this and remove the `strategies.config.php` file in the `%s` addon.', + $classname, + $addonName, + ), \E_USER_DEPRECATED); } } } diff --git a/src/Core/Hooks/Util/StrategiesFileManager.php b/src/Core/Hooks/Util/StrategiesFileManager.php index a39aabc85b..f5d2fe0224 100644 --- a/src/Core/Hooks/Util/StrategiesFileManager.php +++ b/src/Core/Hooks/Util/StrategiesFileManager.php @@ -81,6 +81,9 @@ class StrategiesFileManager throw new HookConfigException(sprintf('Error loading config file %s.', $configFile)); } + /** + * @deprecated 2025.02 Providing strategies via addons is deprecated and will be removed in 5 months. + */ $this->config = array_merge_recursive($config, $this->addonLoader->getActiveAddonConfig(static::CONFIG_NAME)); } } From c8dd900635a89d04398e89b3a2f7ec0dc01907f2 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 8 Feb 2025 07:01:54 +0000 Subject: [PATCH 3/3] Add deprecation note in docs --- doc/StrategyHooks.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/StrategyHooks.md b/doc/StrategyHooks.md index 2960ceeaad..440728783c 100644 --- a/doc/StrategyHooks.md +++ b/doc/StrategyHooks.md @@ -83,6 +83,8 @@ return [ ## Addons +> ⚠️ Since Friendica 2025.02 the strategy hooks for addons are deprecated, please use PHP hooks instead. + The hook logic is useful for decoupling the Friendica core logic, but its primary goal is to modularize Friendica in creating addons. Therefor you can either use the interfaces directly as shown above, or you can place your own `hooks.config.php` file inside a `static` directory directly under your addon core directory.