Merge pull request #11179 from nupplaphil/bug/friendica-11178
Fix Addons-Load for StorageManager
This commit is contained in:
commit
53f06b5122
2 changed files with 20 additions and 16 deletions
|
@ -22,6 +22,7 @@
|
|||
namespace Friendica\Core\Storage\Repository;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -79,11 +80,12 @@ class StorageManager
|
|||
* @param IManageConfigValues $config
|
||||
* @param LoggerInterface $logger
|
||||
* @param L10n $l10n
|
||||
* @param bool $includeAddon (DEVELOP ONLY) Used for testing only - avoids loading addons because of DB direct access
|
||||
*
|
||||
* @throws InvalidClassStorageException in case the active backend class is invalid
|
||||
* @throws StorageException in case of unexpected errors during the active backend class loading
|
||||
*/
|
||||
public function __construct(Database $dba, IManageConfigValues $config, LoggerInterface $logger, L10n $l10n)
|
||||
public function __construct(Database $dba, IManageConfigValues $config, LoggerInterface $logger, L10n $l10n, bool $includeAddon = true)
|
||||
{
|
||||
$this->dba = $dba;
|
||||
$this->config = $config;
|
||||
|
@ -93,6 +95,13 @@ class StorageManager
|
|||
|
||||
$currentName = $this->config->get('storage', 'name');
|
||||
|
||||
/// @fixme Loading the addons & hooks here is really bad practice, but solves https://github.com/friendica/friendica/issues/11178
|
||||
/// clean solution = Making Addon & Hook dynamic and load them inside the constructor, so there's no custom load logic necessary anymore
|
||||
if ($includeAddon) {
|
||||
Addon::loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
|
||||
// you can only use user backends as a "default" backend, so the second parameter is true
|
||||
$this->currentBackend = $this->getWritableStorageByName($currentName);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue