Merge pull request #14795 from Art4/deprecate-strategies-via-addons

Deprecate the strategy concept for addons
This commit is contained in:
Hypolite Petovan 2025-03-09 20:55:25 -04:00 committed by GitHub
commit b2f50301f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 0 deletions

View file

@ -83,6 +83,8 @@ return [
## Addons ## 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. 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. 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.

View file

@ -10,7 +10,9 @@ namespace Friendica\Core\Addon\Model;
use Friendica\Core\Addon\Capability\ICanLoadAddons; use Friendica\Core\Addon\Capability\ICanLoadAddons;
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException; use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Logger\Factory\LoggerFactory;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
class AddonLoader implements ICanLoadAddons class AddonLoader implements ICanLoadAddons
{ {
@ -48,6 +50,25 @@ class AddonLoader implements ICanLoadAddons
throw new AddonInvalidConfigFileException('Error loading config file ' . $configFile); 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 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);
}
}
}
$returnConfig = array_merge_recursive($returnConfig, $config); $returnConfig = array_merge_recursive($returnConfig, $config);
} }

View file

@ -81,6 +81,9 @@ class StrategiesFileManager
throw new HookConfigException(sprintf('Error loading config file %s.', $configFile)); 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)); $this->config = array_merge_recursive($config, $this->addonLoader->getActiveAddonConfig(static::CONFIG_NAME));
} }
} }