From: nupplaPhil Date: Sun, 19 Jan 2020 20:29:36 +0000 (+0100) Subject: Shorten "Configuration" to "Config" again, since the Wrapper is gone X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cb80108957f16011b5b7b1b8961da8cbd78d60c9;p=friendica.git Shorten "Configuration" to "Config" again, since the Wrapper is gone --- diff --git a/doc/AddonStorageBackend.md b/doc/AddonStorageBackend.md index a4f8c0dae7..17c3f04140 100644 --- a/doc/AddonStorageBackend.md +++ b/doc/AddonStorageBackend.md @@ -136,26 +136,26 @@ namespace Friendica\Addon\samplestorage; use Friendica\Model\Storage\IStorage; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\L10n; class SampleStorageBackend implements IStorage { const NAME = 'Sample Storage'; - /** @var IConfiguration */ + /** @var IConfig */ private $config; /** @var L10n */ private $l10n; /** * SampleStorageBackend constructor. - * @param IConfiguration $config The configuration of Friendica + * @param IConfig $config The configuration of Friendica * * You can add here every dynamic class as dependency you like and add them to a private field * Friendica automatically creates these classes and passes them as argument to the constructor */ - public function __construct(IConfiguration $config, L10n $l10n) + public function __construct(IConfig $config, L10n $l10n) { $this->config = $config; $this->l10n = $l10n; diff --git a/src/App.php b/src/App.php index ab56ffb7f9..cfe2c1c1b4 100644 --- a/src/App.php +++ b/src/App.php @@ -9,7 +9,7 @@ use Friendica\App\Arguments; use Friendica\App\BaseURL; use Friendica\App\Authentication; use Friendica\Core\Config\Cache\ConfigCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Config\IPConfiguration; use Friendica\Core\L10n; use Friendica\Core\System; @@ -83,7 +83,7 @@ class App private $currentMobileTheme; /** - * @var IConfiguration The config + * @var IConfig The config */ private $config; @@ -145,7 +145,7 @@ class App /** * @param Database $database The Friendica Database - * @param IConfiguration $config The Configuration + * @param IConfig $config The Configuration * @param App\Mode $mode The mode of this Friendica app * @param BaseURL $baseURL The full base URL of this Friendica app * @param LoggerInterface $logger The current app logger @@ -155,7 +155,7 @@ class App * @param Core\Process $process The process methods * @param IPConfiguration $pConfig Personal configuration */ - public function __construct(Database $database, IConfiguration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfiguration $pConfig) + public function __construct(Database $database, IConfig $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfiguration $pConfig) { $this->database = $database; $this->config = $config; diff --git a/src/App/Authentication.php b/src/App/Authentication.php index 18f6c0f041..9dfc6adb15 100644 --- a/src/App/Authentication.php +++ b/src/App/Authentication.php @@ -8,7 +8,7 @@ namespace Friendica\App; use Exception; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Config\IPConfiguration; use Friendica\Core\Hook; use Friendica\Core\Session; @@ -30,7 +30,7 @@ use Psr\Log\LoggerInterface; */ class Authentication { - /** @var IConfiguration */ + /** @var IConfig */ private $config; /** @var App\Mode */ private $mode; @@ -52,17 +52,17 @@ class Authentication /** * Authentication constructor. * - * @param IConfiguration $config - * @param App\Mode $mode - * @param App\BaseURL $baseUrl - * @param L10n $l10n - * @param Database $dba - * @param LoggerInterface $logger - * @param User\Cookie $cookie + * @param IConfig $config + * @param App\Mode $mode + * @param App\BaseURL $baseUrl + * @param L10n $l10n + * @param Database $dba + * @param LoggerInterface $logger + * @param User\Cookie $cookie * @param Session\ISession $session * @param IPConfiguration $pConfig */ - public function __construct(IConfiguration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfiguration $pConfig) + public function __construct(IConfig $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfiguration $pConfig) { $this->config = $config; $this->mode = $mode; diff --git a/src/App/BaseURL.php b/src/App/BaseURL.php index 7c286514a6..4d20281c8b 100644 --- a/src/App/BaseURL.php +++ b/src/App/BaseURL.php @@ -2,7 +2,7 @@ namespace Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\System; use Friendica\Util\Network; use Friendica\Util\Strings; @@ -37,7 +37,7 @@ class BaseURL /** * The Friendica Config * - * @var IConfiguration + * @var IConfig */ private $config; @@ -253,10 +253,10 @@ class BaseURL } /** - * @param IConfiguration $config The Friendica IConfiguration - * @param array $server The $_SERVER array + * @param IConfig $config The Friendica IConfiguration + * @param array $server The $_SERVER array */ - public function __construct(IConfiguration $config, array $server) + public function __construct(IConfig $config, array $server) { $this->config = $config; $this->server = $server; diff --git a/src/App/Module.php b/src/App/Module.php index 891dc59146..50688710d1 100644 --- a/src/App/Module.php +++ b/src/App/Module.php @@ -149,15 +149,15 @@ class Module /** * Determine the class of the current module * - * @param Arguments $args The Friendica execution arguments - * @param Router $router The Friendica routing instance - * @param Core\Config\IConfiguration $config The Friendica Configuration + * @param Arguments $args The Friendica execution arguments + * @param Router $router The Friendica routing instance + * @param Core\Config\IConfig $config The Friendica Configuration * * @return Module The determined module of this call * * @throws \Exception */ - public function determineClass(Arguments $args, Router $router, Core\Config\IConfiguration $config) + public function determineClass(Arguments $args, Router $router, Core\Config\IConfig $config) { $printNotAllowedAddon = false; diff --git a/src/App/Page.php b/src/App/Page.php index 7531a438eb..408f803225 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -7,7 +7,7 @@ use DOMDocument; use DOMXPath; use Friendica\App; use Friendica\Content\Nav; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Config\IPConfiguration; use Friendica\Core\Hook; use Friendica\Core\L10n; @@ -168,15 +168,15 @@ class Page implements ArrayAccess * - Infinite scroll data * - head.tpl template * - * @param App $app The Friendica App instance - * @param Module $module The loaded Friendica module - * @param L10n $l10n The l10n language instance - * @param IConfiguration $config The Friendica configuration + * @param App $app The Friendica App instance + * @param Module $module The loaded Friendica module + * @param L10n $l10n The l10n language instance + * @param IConfig $config The Friendica configuration * @param IPConfiguration $pConfig The Friendica personal configuration (for user) * * @throws HTTPException\InternalServerErrorException */ - private function initHead(App $app, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pConfig) + private function initHead(App $app, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pConfig) { $interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000); @@ -342,17 +342,17 @@ class Page implements ArrayAccess /** * Executes the creation of the current page and prints it to the screen * - * @param App $app The Friendica App - * @param BaseURL $baseURL The Friendica Base URL - * @param Mode $mode The current node mode - * @param Module $module The loaded Friendica module - * @param L10n $l10n The l10n language class - * @param IConfiguration $config The Configuration of this node + * @param App $app The Friendica App + * @param BaseURL $baseURL The Friendica Base URL + * @param Mode $mode The current node mode + * @param Module $module The loaded Friendica module + * @param L10n $l10n The l10n language class + * @param IConfig $config The Configuration of this node * @param IPConfiguration $pconfig The personal/user configuration * * @throws HTTPException\InternalServerErrorException */ - public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pconfig) + public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pconfig) { $moduleName = $module->getName(); diff --git a/src/Console/AutomaticInstallation.php b/src/Console/AutomaticInstallation.php index 1d378b9deb..12c3b325ae 100644 --- a/src/Console/AutomaticInstallation.php +++ b/src/Console/AutomaticInstallation.php @@ -25,7 +25,7 @@ class AutomaticInstallation extends Console private $configCache; /** - * @var Config\IConfiguration + * @var Config\IConfig */ private $config; @@ -89,7 +89,7 @@ Examples HELP; } - public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfiguration $config, Database $dba, array $argv = null) + public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfig $config, Database $dba, array $argv = null) { parent::__construct($argv); diff --git a/src/Console/Config.php b/src/Console/Config.php index 62a535add4..5103123225 100644 --- a/src/Console/Config.php +++ b/src/Console/Config.php @@ -4,7 +4,7 @@ namespace Friendica\Console; use Asika\SimpleConsole\CommandArgsException; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use RuntimeException; /** @@ -40,7 +40,7 @@ class Config extends \Asika\SimpleConsole\Console */ private $appMode; /** - * @var IConfiguration + * @var IConfig */ private $config; @@ -78,7 +78,7 @@ HELP; return $help; } - public function __construct(App\Mode $appMode, IConfiguration $config, array $argv = null) + public function __construct(App\Mode $appMode, IConfig $config, array $argv = null) { parent::__construct($argv); diff --git a/src/Console/Maintenance.php b/src/Console/Maintenance.php index 8e26f32565..dd20a727ed 100644 --- a/src/Console/Maintenance.php +++ b/src/Console/Maintenance.php @@ -3,7 +3,7 @@ namespace Friendica\Console; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; /** * Sets maintenance mode for this node @@ -19,7 +19,7 @@ class Maintenance extends \Asika\SimpleConsole\Console */ private $appMode; /** - * @var IConfiguration + * @var IConfig */ private $config; @@ -52,7 +52,7 @@ HELP; return $help; } - public function __construct(App\Mode $appMode, IConfiguration $config, $argv = null) + public function __construct(App\Mode $appMode, IConfig $config, $argv = null) { parent::__construct($argv); diff --git a/src/Console/PostUpdate.php b/src/Console/PostUpdate.php index 3691693347..71c5001d74 100644 --- a/src/Console/PostUpdate.php +++ b/src/Console/PostUpdate.php @@ -3,7 +3,7 @@ namespace Friendica\Console; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\L10n; use Friendica\Core\Update; @@ -24,7 +24,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console */ private $appMode; /** - * @var IConfiguration + * @var IConfig */ private $config; /** @@ -46,7 +46,7 @@ HELP; return $help; } - public function __construct(App\Mode $appMode, IConfiguration $config, L10n $l10n, array $argv = null) + public function __construct(App\Mode $appMode, IConfig $config, L10n $l10n, array $argv = null) { parent::__construct($argv); diff --git a/src/Console/ServerBlock.php b/src/Console/ServerBlock.php index a8a75327c4..517b506a1c 100644 --- a/src/Console/ServerBlock.php +++ b/src/Console/ServerBlock.php @@ -5,7 +5,7 @@ namespace Friendica\Console; use Asika\SimpleConsole\CommandArgsException; use Asika\SimpleConsole\Console; use Console_Table; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; /** * Manage blocked servers @@ -20,7 +20,7 @@ class ServerBlock extends Console protected $helpOptions = ['h', 'help', '?']; /** - * @var IConfiguration + * @var IConfig */ private $config; @@ -49,7 +49,7 @@ HELP; return $help; } - public function __construct(IConfiguration $config, $argv = null) + public function __construct(IConfig $config, $argv = null) { parent::__construct($argv); @@ -77,9 +77,9 @@ HELP; /** * Prints the whole list of blocked domains including the reason * - * @param IConfiguration $config + * @param IConfig $config */ - private function printBlockedServers(IConfiguration $config) + private function printBlockedServers(IConfig $config) { $table = new Console_Table(); $table->setHeaders(['Domain', 'Reason']); @@ -93,11 +93,11 @@ HELP; /** * Adds a server to the blocked list * - * @param IConfiguration $config + * @param IConfig $config * * @return int The return code (0 = success, 1 = failed) */ - private function addBlockedServer(IConfiguration $config) + private function addBlockedServer(IConfig $config) { if (count($this->args) < 2 || count($this->args) > 3) { throw new CommandArgsException('Add needs a domain and optional a reason.'); @@ -145,11 +145,11 @@ HELP; /** * Removes a server from the blocked list * - * @param IConfiguration $config + * @param IConfig $config * * @return int The return code (0 = success, 1 = failed) */ - private function removeBlockedServer(IConfiguration $config) + private function removeBlockedServer(IConfig $config) { if (count($this->args) !== 2) { throw new CommandArgsException('Remove needs a second parameter.'); diff --git a/src/Console/Typo.php b/src/Console/Typo.php index a0b6e3691c..eed0a31816 100644 --- a/src/Console/Typo.php +++ b/src/Console/Typo.php @@ -2,7 +2,7 @@ namespace Friendica\Console; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; /** * Tired of chasing typos and finding them after a commit. @@ -15,7 +15,7 @@ class Typo extends \Asika\SimpleConsole\Console protected $helpOptions = ['h', 'help', '?']; /** - * @var IConfiguration + * @var IConfig */ private $config; @@ -36,7 +36,7 @@ HELP; return $help; } - public function __construct(IConfiguration $config, array $argv = null) + public function __construct(IConfig $config, array $argv = null) { parent::__construct($argv); diff --git a/src/Core/BaseConfig.php b/src/Core/BaseConfig.php new file mode 100644 index 0000000000..b464beed1b --- /dev/null +++ b/src/Core/BaseConfig.php @@ -0,0 +1,44 @@ +configCache = $configCache; + $this->configModel = $configModel; + } + + /** + * {@inheritDoc} + */ + public function getCache() + { + return $this->configCache; + } +} diff --git a/src/Core/Cache/MemcacheCache.php b/src/Core/Cache/MemcacheCache.php index b3182a4e40..e3232a564b 100644 --- a/src/Core/Cache/MemcacheCache.php +++ b/src/Core/Cache/MemcacheCache.php @@ -4,7 +4,7 @@ namespace Friendica\Core\Cache; use Exception; use Friendica\Core\BaseCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Memcache; /** @@ -26,7 +26,7 @@ class MemcacheCache extends BaseCache implements IMemoryCache /** * @throws Exception */ - public function __construct(string $hostname, IConfiguration $config) + public function __construct(string $hostname, IConfig $config) { if (!class_exists('Memcache', false)) { throw new Exception('Memcache class isn\'t available'); diff --git a/src/Core/Cache/MemcachedCache.php b/src/Core/Cache/MemcachedCache.php index 29a21c1ad3..26dd593814 100644 --- a/src/Core/Cache/MemcachedCache.php +++ b/src/Core/Cache/MemcachedCache.php @@ -4,7 +4,7 @@ namespace Friendica\Core\Cache; use Exception; use Friendica\Core\BaseCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Memcached; use Psr\Log\LoggerInterface; @@ -40,7 +40,7 @@ class MemcachedCache extends BaseCache implements IMemoryCache * * @throws \Exception */ - public function __construct(string $hostname, IConfiguration $config, LoggerInterface $logger) + public function __construct(string $hostname, IConfig $config, LoggerInterface $logger) { if (!class_exists('Memcached', false)) { throw new Exception('Memcached class isn\'t available'); diff --git a/src/Core/Cache/RedisCache.php b/src/Core/Cache/RedisCache.php index 2a09a4818e..cd4821598d 100644 --- a/src/Core/Cache/RedisCache.php +++ b/src/Core/Cache/RedisCache.php @@ -4,7 +4,7 @@ namespace Friendica\Core\Cache; use Exception; use Friendica\Core\BaseCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Redis; /** @@ -23,7 +23,7 @@ class RedisCache extends BaseCache implements IMemoryCache /** * @throws Exception */ - public function __construct(string $hostname, IConfiguration $config) + public function __construct(string $hostname, IConfig $config) { if (!class_exists('Redis', false)) { throw new Exception('Redis class isn\'t available'); diff --git a/src/Core/Config/Configuration.php b/src/Core/Config/Configuration.php deleted file mode 100644 index 9094441bf6..0000000000 --- a/src/Core/Config/Configuration.php +++ /dev/null @@ -1,42 +0,0 @@ -configCache = $configCache; - $this->configModel = $configModel; - } - - /** - * {@inheritDoc} - */ - public function getCache() - { - return $this->configCache; - } -} diff --git a/src/Core/Config/IConfig.php b/src/Core/Config/IConfig.php new file mode 100644 index 0000000000..102f98ec37 --- /dev/null +++ b/src/Core/Config/IConfig.php @@ -0,0 +1,73 @@ +configAdapter + * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache). + * + * @param string $cat The category of the configuration value + * @param string $key The configuration key to query + * @param mixed $default_value optional, The value to return if key is not set (default: null) + * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false) + * + * @return mixed Stored value or null if it does not exist + */ + function get(string $cat, string $key, $default_value = null, bool $refresh = false); + + /** + * Sets a configuration value for system config + * + * Stores a config value ($value) in the category ($cat) under the key ($key) + * + * Note: Please do not store booleans - convert to 0/1 integer values! + * + * @param string $cat The category of the configuration value + * @param string $key The configuration key to set + * @param mixed $value The value to store + * + * @return bool Operation success + */ + function set(string $cat, string $key, $value); + + /** + * Deletes the given key from the system configuration. + * + * Removes the configured value from the stored cache in $this->configCache + * (@see ConfigCache) and removes it from the database (@see IConfigAdapter). + * + * @param string $cat The category of the configuration value + * @param string $key The configuration key to delete + * + * @return bool + */ + function delete(string $cat, string $key); + + /** + * Returns the Config Cache + * + * @return Cache\ConfigCache + */ + function getCache(); +} diff --git a/src/Core/Config/IConfiguration.php b/src/Core/Config/IConfiguration.php deleted file mode 100644 index 3afe86635b..0000000000 --- a/src/Core/Config/IConfiguration.php +++ /dev/null @@ -1,73 +0,0 @@ -configAdapter - * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache). - * - * @param string $cat The category of the configuration value - * @param string $key The configuration key to query - * @param mixed $default_value optional, The value to return if key is not set (default: null) - * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false) - * - * @return mixed Stored value or null if it does not exist - */ - function get(string $cat, string $key, $default_value = null, bool $refresh = false); - - /** - * Sets a configuration value for system config - * - * Stores a config value ($value) in the category ($cat) under the key ($key) - * - * Note: Please do not store booleans - convert to 0/1 integer values! - * - * @param string $cat The category of the configuration value - * @param string $key The configuration key to set - * @param mixed $value The value to store - * - * @return bool Operation success - */ - function set(string $cat, string $key, $value); - - /** - * Deletes the given key from the system configuration. - * - * Removes the configured value from the stored cache in $this->configCache - * (@see ConfigCache) and removes it from the database (@see IConfigAdapter). - * - * @param string $cat The category of the configuration value - * @param string $key The configuration key to delete - * - * @return bool - */ - function delete(string $cat, string $key); - - /** - * Returns the Config Cache - * - * @return Cache\ConfigCache - */ - function getCache(); -} diff --git a/src/Core/Config/JitConfig.php b/src/Core/Config/JitConfig.php new file mode 100644 index 0000000000..e4cec62cb0 --- /dev/null +++ b/src/Core/Config/JitConfig.php @@ -0,0 +1,122 @@ +db_loaded = []; + + $this->load(); + } + + /** + * {@inheritDoc} + * + */ + public function load(string $cat = 'config') + { + // If not connected, do nothing + if (!$this->configModel->isConnected()) { + return; + } + + $config = $this->configModel->load($cat); + + if (!empty($config[$cat])) { + foreach ($config[$cat] as $key => $value) { + $this->db_loaded[$cat][$key] = true; + } + } + + // load the whole category out of the DB into the cache + $this->configCache->load($config, true); + } + + /** + * {@inheritDoc} + */ + public function get(string $cat, string $key, $default_value = null, bool $refresh = false) + { + // if the value isn't loaded or refresh is needed, load it to the cache + if ($this->configModel->isConnected() && + (empty($this->db_loaded[$cat][$key]) || + $refresh)) { + + $dbvalue = $this->configModel->get($cat, $key); + + if (isset($dbvalue)) { + $this->configCache->set($cat, $key, $dbvalue); + unset($dbvalue); + } + + $this->db_loaded[$cat][$key] = true; + } + + // use the config cache for return + $result = $this->configCache->get($cat, $key); + + return (isset($result)) ? $result : $default_value; + } + + /** + * {@inheritDoc} + */ + public function set(string $cat, string $key, $value) + { + // set the cache first + $cached = $this->configCache->set($cat, $key, $value); + + // If there is no connected adapter, we're finished + if (!$this->configModel->isConnected()) { + return $cached; + } + + $stored = $this->configModel->set($cat, $key, $value); + + $this->db_loaded[$cat][$key] = $stored; + + return $cached && $stored; + } + + /** + * {@inheritDoc} + */ + public function delete(string $cat, string $key) + { + $cacheRemoved = $this->configCache->delete($cat, $key); + + if (isset($this->db_loaded[$cat][$key])) { + unset($this->db_loaded[$cat][$key]); + } + + if (!$this->configModel->isConnected()) { + return $cacheRemoved; + } + + $storeRemoved = $this->configModel->delete($cat, $key); + + return $cacheRemoved || $storeRemoved; + } +} diff --git a/src/Core/Config/JitConfiguration.php b/src/Core/Config/JitConfiguration.php deleted file mode 100644 index 07f6d0e079..0000000000 --- a/src/Core/Config/JitConfiguration.php +++ /dev/null @@ -1,121 +0,0 @@ -db_loaded = []; - - $this->load(); - } - - /** - * {@inheritDoc} - * - */ - public function load(string $cat = 'config') - { - // If not connected, do nothing - if (!$this->configModel->isConnected()) { - return; - } - - $config = $this->configModel->load($cat); - - if (!empty($config[$cat])) { - foreach ($config[$cat] as $key => $value) { - $this->db_loaded[$cat][$key] = true; - } - } - - // load the whole category out of the DB into the cache - $this->configCache->load($config, true); - } - - /** - * {@inheritDoc} - */ - public function get(string $cat, string $key, $default_value = null, bool $refresh = false) - { - // if the value isn't loaded or refresh is needed, load it to the cache - if ($this->configModel->isConnected() && - (empty($this->db_loaded[$cat][$key]) || - $refresh)) { - - $dbvalue = $this->configModel->get($cat, $key); - - if (isset($dbvalue)) { - $this->configCache->set($cat, $key, $dbvalue); - unset($dbvalue); - } - - $this->db_loaded[$cat][$key] = true; - } - - // use the config cache for return - $result = $this->configCache->get($cat, $key); - - return (isset($result)) ? $result : $default_value; - } - - /** - * {@inheritDoc} - */ - public function set(string $cat, string $key, $value) - { - // set the cache first - $cached = $this->configCache->set($cat, $key, $value); - - // If there is no connected adapter, we're finished - if (!$this->configModel->isConnected()) { - return $cached; - } - - $stored = $this->configModel->set($cat, $key, $value); - - $this->db_loaded[$cat][$key] = $stored; - - return $cached && $stored; - } - - /** - * {@inheritDoc} - */ - public function delete(string $cat, string $key) - { - $cacheRemoved = $this->configCache->delete($cat, $key); - - if (isset($this->db_loaded[$cat][$key])) { - unset($this->db_loaded[$cat][$key]); - } - - if (!$this->configModel->isConnected()) { - return $cacheRemoved; - } - - $storeRemoved = $this->configModel->delete($cat, $key); - - return $cacheRemoved || $storeRemoved; - } -} diff --git a/src/Core/Config/PreloadConfig.php b/src/Core/Config/PreloadConfig.php new file mode 100644 index 0000000000..50ea9200f9 --- /dev/null +++ b/src/Core/Config/PreloadConfig.php @@ -0,0 +1,117 @@ +config_loaded = false; + + $this->load(); + } + + /** + * {@inheritDoc} + * + * This loads all config values everytime load is called + * + */ + public function load(string $cat = 'config') + { + // Don't load the whole configuration twice + if ($this->config_loaded) { + return; + } + + // If not connected, do nothing + if (!$this->configModel->isConnected()) { + return; + } + + $config = $this->configModel->load(); + $this->config_loaded = true; + + // load the whole category out of the DB into the cache + $this->configCache->load($config, true); + } + + /** + * {@inheritDoc} + */ + public function get(string $cat, string $key, $default_value = null, bool $refresh = false) + { + if ($refresh) { + if ($this->configModel->isConnected()) { + $config = $this->configModel->get($cat, $key); + if (isset($config)) { + $this->configCache->set($cat, $key, $config); + } + } + } + + // use the config cache for return + $result = $this->configCache->get($cat, $key); + + return (isset($result)) ? $result : $default_value; + } + + /** + * {@inheritDoc} + */ + public function set(string $cat, string $key, $value) + { + if (!$this->config_loaded) { + $this->load(); + } + + // set the cache first + $cached = $this->configCache->set($cat, $key, $value); + + // If there is no connected adapter, we're finished + if (!$this->configModel->isConnected()) { + return $cached; + } + + $stored = $this->configModel->set($cat, $key, $value); + + return $cached && $stored; + } + + /** + * {@inheritDoc} + */ + public function delete(string $cat, string $key) + { + if ($this->config_loaded) { + $this->load(); + } + + $cacheRemoved = $this->configCache->delete($cat, $key); + + if (!$this->configModel->isConnected()) { + return $cacheRemoved; + } + + $storeRemoved = $this->configModel->delete($cat, $key); + + return $cacheRemoved || $storeRemoved; + } +} diff --git a/src/Core/Config/PreloadConfiguration.php b/src/Core/Config/PreloadConfiguration.php deleted file mode 100644 index d54f1b0636..0000000000 --- a/src/Core/Config/PreloadConfiguration.php +++ /dev/null @@ -1,116 +0,0 @@ -config_loaded = false; - - $this->load(); - } - - /** - * {@inheritDoc} - * - * This loads all config values everytime load is called - * - */ - public function load(string $cat = 'config') - { - // Don't load the whole configuration twice - if ($this->config_loaded) { - return; - } - - // If not connected, do nothing - if (!$this->configModel->isConnected()) { - return; - } - - $config = $this->configModel->load(); - $this->config_loaded = true; - - // load the whole category out of the DB into the cache - $this->configCache->load($config, true); - } - - /** - * {@inheritDoc} - */ - public function get(string $cat, string $key, $default_value = null, bool $refresh = false) - { - if ($refresh) { - if ($this->configModel->isConnected()) { - $config = $this->configModel->get($cat, $key); - if (isset($config)) { - $this->configCache->set($cat, $key, $config); - } - } - } - - // use the config cache for return - $result = $this->configCache->get($cat, $key); - - return (isset($result)) ? $result : $default_value; - } - - /** - * {@inheritDoc} - */ - public function set(string $cat, string $key, $value) - { - if (!$this->config_loaded) { - $this->load(); - } - - // set the cache first - $cached = $this->configCache->set($cat, $key, $value); - - // If there is no connected adapter, we're finished - if (!$this->configModel->isConnected()) { - return $cached; - } - - $stored = $this->configModel->set($cat, $key, $value); - - return $cached && $stored; - } - - /** - * {@inheritDoc} - */ - public function delete(string $cat, string $key) - { - if ($this->config_loaded) { - $this->load(); - } - - $cacheRemoved = $this->configCache->delete($cat, $key); - - if (!$this->configModel->isConnected()) { - return $cacheRemoved; - } - - $storeRemoved = $this->configModel->delete($cat, $key); - - return $cacheRemoved || $storeRemoved; - } -} diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 0238af3bd1..9fec8735f0 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -2,7 +2,7 @@ namespace Friendica\Core; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Session\ISession; use Friendica\Database\Database; use Friendica\Util\Strings; @@ -40,7 +40,7 @@ class L10n */ private $logger; - public function __construct(IConfiguration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get) + public function __construct(IConfig $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get) { $this->dba = $dba; $this->logger = $logger; diff --git a/src/Core/Process.php b/src/Core/Process.php index 60ad14aa6d..b0345b05bb 100644 --- a/src/Core/Process.php +++ b/src/Core/Process.php @@ -3,7 +3,7 @@ namespace Friendica\Core; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Psr\Log\LoggerInterface; /** @@ -28,7 +28,7 @@ final class Process private $mode; /** - * @var IConfiguration + * @var IConfig */ private $config; @@ -37,7 +37,7 @@ final class Process */ private $basePath; - public function __construct(LoggerInterface $logger, App\Mode $mode, IConfiguration $config, string $basepath) + public function __construct(LoggerInterface $logger, App\Mode $mode, IConfig $config, string $basepath) { $this->logger = $logger; $this->mode = $mode; diff --git a/src/Core/StorageManager.php b/src/Core/StorageManager.php index 067885c447..8d5df2d613 100644 --- a/src/Core/StorageManager.php +++ b/src/Core/StorageManager.php @@ -3,7 +3,7 @@ namespace Friendica\Core; use Exception; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Database\Database; use Friendica\Model\Storage; use Psr\Log\LoggerInterface; @@ -35,7 +35,7 @@ class StorageManager /** @var Database */ private $dba; - /** @var IConfiguration */ + /** @var IConfig */ private $config; /** @var LoggerInterface */ private $logger; @@ -47,11 +47,11 @@ class StorageManager /** * @param Database $dba - * @param IConfiguration $config + * @param IConfig $config * @param LoggerInterface $logger * @param L10n $l10n */ - public function __construct(Database $dba, IConfiguration $config, LoggerInterface $logger, L10n $l10n) + public function __construct(Database $dba, IConfig $config, LoggerInterface $logger, L10n $l10n) { $this->dba = $dba; $this->config = $config; diff --git a/src/DI.php b/src/DI.php index a76fa4666b..1109b1afb3 100644 --- a/src/DI.php +++ b/src/DI.php @@ -133,11 +133,11 @@ abstract class DI } /** - * @return Core\Config\IConfiguration + * @return Core\Config\IConfig */ public static function config() { - return self::$dice->create(Core\Config\IConfiguration::class); + return self::$dice->create(Core\Config\IConfig::class); } /** diff --git a/src/Factory/CacheFactory.php b/src/Factory/CacheFactory.php index 8cf7fcd66a..4dfda5f2c5 100644 --- a/src/Factory/CacheFactory.php +++ b/src/Factory/CacheFactory.php @@ -5,7 +5,7 @@ namespace Friendica\Factory; use Friendica\App\BaseURL; use Friendica\Core\Cache; use Friendica\Core\Cache\ICache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Database\Database; use Friendica\Util\Profiler; use Psr\Log\LoggerInterface; @@ -25,7 +25,7 @@ class CacheFactory const DEFAULT_TYPE = Cache\Type::DATABASE; /** - * @var IConfiguration The IConfiguration to read parameters out of the config + * @var IConfig The IConfiguration to read parameters out of the config */ private $config; @@ -49,7 +49,7 @@ class CacheFactory */ private $logger; - public function __construct(BaseURL $baseURL, IConfiguration $config, Database $dba, Profiler $profiler, LoggerInterface $logger) + public function __construct(BaseURL $baseURL, IConfig $config, Database $dba, Profiler $profiler, LoggerInterface $logger) { $this->hostname = $baseURL->getHostname(); $this->config = $config; diff --git a/src/Factory/ConfigFactory.php b/src/Factory/ConfigFactory.php index ecec1e2a73..f912399345 100644 --- a/src/Factory/ConfigFactory.php +++ b/src/Factory/ConfigFactory.php @@ -27,14 +27,14 @@ class ConfigFactory * @param Cache\ConfigCache $configCache The config cache of this adapter * @param ConfigModel $configModel The configuration model * - * @return Config\IConfiguration + * @return Config\IConfig */ public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel) { if ($configCache->get('system', 'config_adapter') === 'preload') { - $configuration = new Config\PreloadConfiguration($configCache, $configModel); + $configuration = new Config\PreloadConfig($configCache, $configModel); } else { - $configuration = new Config\JitConfiguration($configCache, $configModel); + $configuration = new Config\JitConfig($configCache, $configModel); } diff --git a/src/Factory/LockFactory.php b/src/Factory/LockFactory.php index 8ea0642b18..6d739ea41a 100644 --- a/src/Factory/LockFactory.php +++ b/src/Factory/LockFactory.php @@ -4,7 +4,7 @@ namespace Friendica\Factory; use Friendica\Core\Cache\IMemoryCache; use Friendica\Core\Cache\Type; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Lock; use Friendica\Database\Database; use Psr\Log\LoggerInterface; @@ -24,7 +24,7 @@ class LockFactory const DEFAULT_DRIVER = 'default'; /** - * @var IConfiguration The configuration to read parameters out of the config + * @var IConfig The configuration to read parameters out of the config */ private $config; @@ -43,7 +43,7 @@ class LockFactory */ private $logger; - public function __construct(CacheFactory $cacheFactory, IConfiguration $config, Database $dba, LoggerInterface $logger) + public function __construct(CacheFactory $cacheFactory, IConfig $config, Database $dba, LoggerInterface $logger) { $this->cacheFactory = $cacheFactory; $this->config = $config; diff --git a/src/Factory/LoggerFactory.php b/src/Factory/LoggerFactory.php index 0dae19a250..b2450a9662 100644 --- a/src/Factory/LoggerFactory.php +++ b/src/Factory/LoggerFactory.php @@ -2,7 +2,7 @@ namespace Friendica\Factory; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Logger; use Friendica\Database\Database; use Friendica\Network\HTTPException\InternalServerErrorException; @@ -49,14 +49,14 @@ class LoggerFactory /** * Creates a new PSR-3 compliant logger instances * - * @param Database $database The Friendica Database instance - * @param IConfiguration $config The config - * @param Profiler $profiler The profiler of the app - * @param FileSystem $fileSystem FileSystem utils + * @param Database $database The Friendica Database instance + * @param IConfig $config The config + * @param Profiler $profiler The profiler of the app + * @param FileSystem $fileSystem FileSystem utils * * @return LoggerInterface The PSR-3 compliant logger instance */ - public function create(Database $database, IConfiguration $config, Profiler $profiler, FileSystem $fileSystem) + public function create(Database $database, IConfig $config, Profiler $profiler, FileSystem $fileSystem) { if (empty($config->get('system', 'debugging', false))) { $logger = new VoidLogger(); @@ -137,16 +137,16 @@ class LoggerFactory * * It should never get filled during normal usage of Friendica * - * @param IConfiguration $config The config - * @param Profiler $profiler The profiler of the app - * @param FileSystem $fileSystem FileSystem utils + * @param IConfig $config The config + * @param Profiler $profiler The profiler of the app + * @param FileSystem $fileSystem FileSystem utils * * @return LoggerInterface The PSR-3 compliant logger instance * * @throws InternalServerErrorException * @throws \Exception */ - public static function createDev(IConfiguration $config, Profiler $profiler, FileSystem $fileSystem) + public static function createDev(IConfig $config, Profiler $profiler, FileSystem $fileSystem) { $debugging = $config->get('system', 'debugging'); $stream = $config->get('system', 'dlogfile'); diff --git a/src/Factory/SessionFactory.php b/src/Factory/SessionFactory.php index 4ca83830a6..d4ad1e7ca1 100644 --- a/src/Factory/SessionFactory.php +++ b/src/Factory/SessionFactory.php @@ -5,7 +5,7 @@ namespace Friendica\Factory; use Friendica\App; use Friendica\Core\Cache\ICache; use Friendica\Core\Cache\Type; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\Database; @@ -29,7 +29,7 @@ class SessionFactory /** * @param App\Mode $mode * @param App\BaseURL $baseURL - * @param IConfiguration $config + * @param IConfig $config * @param Database $dba * @param ICache $cache * @param LoggerInterface $logger @@ -37,7 +37,7 @@ class SessionFactory * * @return Session\ISession */ - public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfiguration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = []) + public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfig $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = []) { $stamp1 = microtime(true); $session = null; diff --git a/src/Model/Storage/Filesystem.php b/src/Model/Storage/Filesystem.php index 60ed0252aa..3bb6809b28 100644 --- a/src/Model/Storage/Filesystem.php +++ b/src/Model/Storage/Filesystem.php @@ -6,7 +6,7 @@ namespace Friendica\Model\Storage; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\L10n; use Friendica\Util\Strings; use Psr\Log\LoggerInterface; @@ -28,7 +28,7 @@ class Filesystem extends AbstractStorage // Default base folder const DEFAULT_BASE_FOLDER = 'storage'; - /** @var IConfiguration */ + /** @var IConfig */ private $config; /** @var string */ @@ -37,11 +37,11 @@ class Filesystem extends AbstractStorage /** * Filesystem constructor. * - * @param IConfiguration $config + * @param IConfig $config * @param LoggerInterface $logger * @param L10n $l10n */ - public function __construct(IConfiguration $config, LoggerInterface $logger, L10n $l10n) + public function __construct(IConfig $config, LoggerInterface $logger, L10n $l10n) { parent::__construct($l10n, $logger); diff --git a/src/Model/User/Cookie.php b/src/Model/User/Cookie.php index e065d33e2e..ba6253c5cd 100644 --- a/src/Model/User/Cookie.php +++ b/src/Model/User/Cookie.php @@ -3,7 +3,7 @@ namespace Friendica\Model\User; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; /** * Interacting with the Friendica Cookie of a user @@ -32,7 +32,7 @@ class Cookie /** @var array The $_COOKIE array */ private $cookie; - public function __construct(IConfiguration $config, App\BaseURL $baseURL, array $server = [], array $cookie = []) + public function __construct(IConfig $config, App\BaseURL $baseURL, array $server = [], array $cookie = []) { if (!empty($server['REMOTE_ADDR'])) { $this->remoteAddr = $server['REMOTE_ADDR']; diff --git a/src/Util/Profiler.php b/src/Util/Profiler.php index d166210e33..e4061f5194 100644 --- a/src/Util/Profiler.php +++ b/src/Util/Profiler.php @@ -3,7 +3,7 @@ namespace Friendica\Util; use Friendica\Core\Config\Cache\ConfigCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -47,9 +47,9 @@ class Profiler implements ContainerInterface /** * Updates the enabling of the current profiler * - * @param IConfiguration $config + * @param IConfig $config */ - public function update(IConfiguration $config) + public function update(IConfig $config) { $this->enabled = $config->get('system', 'profiler'); $this->rendertime = $config->get('rendertime', 'callstack'); diff --git a/static/dependencies.config.php b/static/dependencies.config.php index b4fa7d247a..cf2d6dd3ff 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -72,13 +72,13 @@ return [ ['determine', [], Dice::CHAIN_CALL], ], ], - Config\IConfiguration::class => [ + Config\IConfig::class => [ 'instanceOf' => Factory\ConfigFactory::class, 'call' => [ ['createConfig', [], Dice::CHAIN_CALL], ], ], - Config\IPConfiguration::class => [ + Config\IPConfiguration::class => [ 'instanceOf' => Factory\ConfigFactory::class, 'call' => [ ['createPConfig', [], Dice::CHAIN_CALL], diff --git a/tests/Util/AppMockTrait.php b/tests/Util/AppMockTrait.php index f0231b280d..353676932f 100644 --- a/tests/Util/AppMockTrait.php +++ b/tests/Util/AppMockTrait.php @@ -22,7 +22,7 @@ trait AppMockTrait protected $app; /** - * @var MockInterface|Config\IConfiguration The mocked Config Cache + * @var MockInterface|Config\IConfig The mocked Config Cache */ protected $configMock; @@ -64,9 +64,9 @@ trait AppMockTrait // Disable the adapter $configModel->shouldReceive('isConnected')->andReturn(false); - $config = new Config\JitConfiguration($this->configMock, $configModel); + $config = new Config\JitConfig($this->configMock, $configModel); $this->dice->shouldReceive('create') - ->with(Config\IConfiguration::class) + ->with(Config\IConfig::class) ->andReturn($config); // Mocking App and most used functions diff --git a/tests/functional/DependencyCheckTest.php b/tests/functional/DependencyCheckTest.php index 4e05845f29..468e967d65 100644 --- a/tests/functional/DependencyCheckTest.php +++ b/tests/functional/DependencyCheckTest.php @@ -7,7 +7,7 @@ use Friendica\App; use Friendica\Core\Cache\ICache; use Friendica\Core\Cache\IMemoryCache; use Friendica\Core\Config\Cache\ConfigCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Lock\ILock; use Friendica\Database\Database; use Friendica\Test\Util\VFSTrait; @@ -115,10 +115,10 @@ class dependencyCheck extends TestCase public function testConfiguration() { - /** @var IConfiguration $config */ - $config = $this->dice->create(IConfiguration::class); + /** @var IConfig $config */ + $config = $this->dice->create(IConfig::class); - $this->assertInstanceOf(IConfiguration::class, $config); + $this->assertInstanceOf(IConfig::class, $config); $this->assertNotEmpty($config->get('database', 'username')); } @@ -133,8 +133,8 @@ class dependencyCheck extends TestCase public function testDevLogger() { - /** @var IConfiguration $config */ - $config = $this->dice->create(IConfiguration::class); + /** @var IConfig $config */ + $config = $this->dice->create(IConfig::class); $config->set('system', 'dlogfile', $this->root->url() . '/friendica.log'); /** @var LoggerInterface $logger */ diff --git a/tests/include/ApiTest.php b/tests/include/ApiTest.php index f702d70bca..5180d3b36d 100644 --- a/tests/include/ApiTest.php +++ b/tests/include/ApiTest.php @@ -7,7 +7,7 @@ namespace Friendica\Test; use Dice\Dice; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Config\IPConfiguration; use Friendica\Core\Protocol; use Friendica\Core\Session; @@ -47,7 +47,7 @@ class ApiTest extends DatabaseTest /** @var App */ protected $app; - /** @var IConfiguration */ + /** @var IConfig */ protected $config; /** @var Dice */ @@ -69,8 +69,8 @@ class ApiTest extends DatabaseTest /** @var Database $dba */ $dba = $this->dice->create(Database::class); - /** @var IConfiguration $config */ - $this->config = $this->dice->create(IConfiguration::class); + /** @var IConfig $config */ + $this->config = $this->dice->create(IConfig::class); $this->config->set('system', 'url', 'http://localhost'); $this->config->set('system', 'hostname', 'localhost'); diff --git a/tests/src/App/ModuleTest.php b/tests/src/App/ModuleTest.php index f1ac6bb92e..f76d51843c 100644 --- a/tests/src/App/ModuleTest.php +++ b/tests/src/App/ModuleTest.php @@ -3,7 +3,7 @@ namespace Friendica\Test\src\App; use Friendica\App; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\LegacyModule; use Friendica\Module\HTTPException\PageNotFound; use Friendica\Module\WellKnown\HostMeta; @@ -149,7 +149,7 @@ class ModuleTest extends DatabaseTest */ public function testModuleClass($assert, string $name, string $command, bool $privAdd) { - $config = \Mockery::mock(IConfiguration::class); + $config = \Mockery::mock(IConfig::class); $config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once(); $router = (new App\Router([]))->loadRoutes(include __DIR__ . '/../../../static/routes.config.php'); diff --git a/tests/src/Console/ConfigConsoleTest.php b/tests/src/Console/ConfigConsoleTest.php index 51342bf169..77ef45b74e 100644 --- a/tests/src/Console/ConfigConsoleTest.php +++ b/tests/src/Console/ConfigConsoleTest.php @@ -5,7 +5,7 @@ namespace Friendica\Test\src\Console; use Friendica\App; use Friendica\App\Mode; use Friendica\Console\Config; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Mockery\MockInterface; class ConfigConsoleTest extends ConsoleTest @@ -29,7 +29,7 @@ class ConfigConsoleTest extends ConsoleTest $this->appMode->shouldReceive('has') ->andReturn(true); - $this->configMock = \Mockery::mock(IConfiguration::class); + $this->configMock = \Mockery::mock(IConfig::class); } function testSetGetKeyValue() diff --git a/tests/src/Console/ServerBlockConsoleTest.php b/tests/src/Console/ServerBlockConsoleTest.php index ef6cc0dacb..c7c936b941 100644 --- a/tests/src/Console/ServerBlockConsoleTest.php +++ b/tests/src/Console/ServerBlockConsoleTest.php @@ -3,7 +3,7 @@ namespace Friendica\Test\src\Console; use Friendica\Console\ServerBlock; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; class ServerBlockConsoleTest extends ConsoleTest { @@ -22,7 +22,7 @@ class ServerBlockConsoleTest extends ConsoleTest { parent::setUp(); - $this->configMock = \Mockery::mock(IConfiguration::class); + $this->configMock = \Mockery::mock(IConfig::class); } /** diff --git a/tests/src/Core/Cache/MemcacheCacheTest.php b/tests/src/Core/Cache/MemcacheCacheTest.php index be7946717e..f6d1101c4e 100644 --- a/tests/src/Core/Cache/MemcacheCacheTest.php +++ b/tests/src/Core/Cache/MemcacheCacheTest.php @@ -3,7 +3,7 @@ namespace Friendica\Test\src\Core\Cache; use Friendica\Core\Cache\MemcacheCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; /** * @requires extension memcache @@ -13,7 +13,7 @@ class MemcacheCacheTest extends MemoryCacheTest { protected function getInstance() { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost'; diff --git a/tests/src/Core/Cache/MemcachedCacheTest.php b/tests/src/Core/Cache/MemcachedCacheTest.php index addbde6275..add400678b 100644 --- a/tests/src/Core/Cache/MemcachedCacheTest.php +++ b/tests/src/Core/Cache/MemcachedCacheTest.php @@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Cache; use Friendica\Core\Cache\MemcachedCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Psr\Log\NullLogger; /** @@ -15,7 +15,7 @@ class MemcachedCacheTest extends MemoryCacheTest { protected function getInstance() { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost'; diff --git a/tests/src/Core/Cache/RedisCacheTest.php b/tests/src/Core/Cache/RedisCacheTest.php index 53c2ecc833..e7a3ffb310 100644 --- a/tests/src/Core/Cache/RedisCacheTest.php +++ b/tests/src/Core/Cache/RedisCacheTest.php @@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Cache; use Friendica\Core\Cache\RedisCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; /** * @requires extension redis @@ -14,7 +14,7 @@ class RedisCacheTest extends MemoryCacheTest { protected function getInstance() { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $host = $_SERVER['REDIS_HOST'] ?? 'localhost'; diff --git a/tests/src/Core/Config/ConfigurationTest.php b/tests/src/Core/Config/ConfigurationTest.php index 15c96ca936..4090407aea 100644 --- a/tests/src/Core/Config/ConfigurationTest.php +++ b/tests/src/Core/Config/ConfigurationTest.php @@ -3,7 +3,7 @@ namespace Friendica\Test\src\Core\Config; use Friendica\Core\Config\Cache\ConfigCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Model\Config\Config as ConfigModel; use Friendica\Test\MockedTest; use Mockery\MockInterface; @@ -17,7 +17,7 @@ abstract class ConfigurationTest extends MockedTest /** @var ConfigCache */ protected $configCache; - /** @var IConfiguration */ + /** @var IConfig */ protected $testedConfig; /** @@ -46,7 +46,7 @@ abstract class ConfigurationTest extends MockedTest } /** - * @return IConfiguration + * @return IConfig */ public abstract function getInstance(); diff --git a/tests/src/Core/Config/JitConfigurationTest.php b/tests/src/Core/Config/JitConfigurationTest.php index 1a9723a94e..520dcc2ef1 100644 --- a/tests/src/Core/Config/JitConfigurationTest.php +++ b/tests/src/Core/Config/JitConfigurationTest.php @@ -2,13 +2,13 @@ namespace Friendica\Test\src\Core\Config; -use Friendica\Core\Config\JitConfiguration; +use Friendica\Core\Config\JitConfig; class JitConfigurationTest extends ConfigurationTest { public function getInstance() { - return new JitConfiguration($this->configCache, $this->configModel); + return new JitConfig($this->configCache, $this->configModel); } /** diff --git a/tests/src/Core/Config/PreloadConfigurationTest.php b/tests/src/Core/Config/PreloadConfigurationTest.php index 88044395b1..1325afefb5 100644 --- a/tests/src/Core/Config/PreloadConfigurationTest.php +++ b/tests/src/Core/Config/PreloadConfigurationTest.php @@ -2,13 +2,13 @@ namespace Friendica\Test\src\Core\Config; -use Friendica\Core\Config\PreloadConfiguration; +use Friendica\Core\Config\PreloadConfig; class PreloadConfigurationTest extends ConfigurationTest { public function getInstance() { - return new PreloadConfiguration($this->configCache, $this->configModel); + return new PreloadConfig($this->configCache, $this->configModel); } /** diff --git a/tests/src/Core/Lock/MemcacheCacheLockTest.php b/tests/src/Core/Lock/MemcacheCacheLockTest.php index 9e111fbb92..b7ef5d376d 100644 --- a/tests/src/Core/Lock/MemcacheCacheLockTest.php +++ b/tests/src/Core/Lock/MemcacheCacheLockTest.php @@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Lock; use Friendica\Core\Cache\MemcacheCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Lock\CacheLock; /** @@ -15,7 +15,7 @@ class MemcacheCacheLockTest extends LockTest { protected function getInstance() { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost'; diff --git a/tests/src/Core/Lock/MemcachedCacheLockTest.php b/tests/src/Core/Lock/MemcachedCacheLockTest.php index 41b16abc7f..69272007a4 100644 --- a/tests/src/Core/Lock/MemcachedCacheLockTest.php +++ b/tests/src/Core/Lock/MemcachedCacheLockTest.php @@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Lock; use Friendica\Core\Cache\MemcachedCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Lock\CacheLock; use Psr\Log\NullLogger; @@ -16,7 +16,7 @@ class MemcachedCacheLockTest extends LockTest { protected function getInstance() { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost'; diff --git a/tests/src/Core/Lock/RedisCacheLockTest.php b/tests/src/Core/Lock/RedisCacheLockTest.php index bfda18b24d..41a3c2318a 100644 --- a/tests/src/Core/Lock/RedisCacheLockTest.php +++ b/tests/src/Core/Lock/RedisCacheLockTest.php @@ -4,7 +4,7 @@ namespace Friendica\Test\src\Core\Lock; use Friendica\Core\Cache\RedisCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\Lock\CacheLock; /** @@ -15,7 +15,7 @@ class RedisCacheLockTest extends LockTest { protected function getInstance() { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $host = $_SERVER['REDIS_HOST'] ?? 'localhost'; diff --git a/tests/src/Core/Lock/SemaphoreLockTest.php b/tests/src/Core/Lock/SemaphoreLockTest.php index 6b4daf8874..ab4f98c63e 100644 --- a/tests/src/Core/Lock/SemaphoreLockTest.php +++ b/tests/src/Core/Lock/SemaphoreLockTest.php @@ -4,8 +4,8 @@ namespace Friendica\Test\src\Core\Lock; use Dice\Dice; use Friendica\App; -use Friendica\Core\Config\IConfiguration; -use Friendica\Core\Config\JitConfiguration; +use Friendica\Core\Config\IConfig; +use Friendica\Core\Config\JitConfig; use Friendica\Core\Lock\SemaphoreLock; use Friendica\DI; use Mockery\MockInterface; @@ -21,12 +21,12 @@ class SemaphoreLockTest extends LockTest $app->shouldReceive('getHostname')->andReturn('friendica.local'); $dice->shouldReceive('create')->with(App::class)->andReturn($app); - $configMock = \Mockery::mock(JitConfiguration::class); + $configMock = \Mockery::mock(JitConfig::class); $configMock ->shouldReceive('get') ->with('system', 'temppath', NULL, false) ->andReturn('/tmp/'); - $dice->shouldReceive('create')->with(IConfiguration::class)->andReturn($configMock); + $dice->shouldReceive('create')->with(IConfig::class)->andReturn($configMock); // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject DI::init($dice); diff --git a/tests/src/Core/StorageManagerTest.php b/tests/src/Core/StorageManagerTest.php index 118d4bb57b..b626978863 100644 --- a/tests/src/Core/StorageManagerTest.php +++ b/tests/src/Core/StorageManagerTest.php @@ -3,8 +3,8 @@ namespace Friendica\Test\src\Core; use Dice\Dice; -use Friendica\Core\Config\IConfiguration; -use Friendica\Core\Config\PreloadConfiguration; +use Friendica\Core\Config\IConfig; +use Friendica\Core\Config\PreloadConfig; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Session\ISession; @@ -28,7 +28,7 @@ class StorageManagerTest extends DatabaseTest { /** @var Database */ private $dba; - /** @var IConfiguration */ + /** @var IConfig */ private $config; /** @var LoggerInterface */ private $logger; @@ -56,7 +56,7 @@ class StorageManagerTest extends DatabaseTest $this->dba = new StaticDatabase($configCache, $profiler, $this->logger); $configModel = new Config($this->dba); - $this->config = new PreloadConfiguration($configCache, $configModel); + $this->config = new PreloadConfig($configCache, $configModel); $this->l10n = \Mockery::mock(L10n::class); } diff --git a/tests/src/Model/Storage/FilesystemStorageTest.php b/tests/src/Model/Storage/FilesystemStorageTest.php index f809585585..eb1336c829 100644 --- a/tests/src/Model/Storage/FilesystemStorageTest.php +++ b/tests/src/Model/Storage/FilesystemStorageTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Model\Storage; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Core\L10n; use Friendica\Model\Storage\Filesystem; use Friendica\Model\Storage\IStorage; @@ -17,7 +17,7 @@ class FilesystemStorageTest extends StorageTest { use VFSTrait; - /** @var MockInterface|IConfiguration */ + /** @var MockInterface|IConfig */ protected $config; protected function setUp() @@ -37,7 +37,7 @@ class FilesystemStorageTest extends StorageTest /** @var MockInterface|L10n $l10n */ $l10n = \Mockery::mock(L10n::class)->makePartial(); - $this->config = \Mockery::mock(IConfiguration::class); + $this->config = \Mockery::mock(IConfig::class); $this->config->shouldReceive('get') ->with('storage', 'filesystem_path', Filesystem::DEFAULT_BASE_FOLDER) ->andReturn($this->root->getChild('storage')->url()); diff --git a/tests/src/Model/User/CookieTest.php b/tests/src/Model/User/CookieTest.php index f66e5a6ae6..2c791acf84 100644 --- a/tests/src/Model/User/CookieTest.php +++ b/tests/src/Model/User/CookieTest.php @@ -3,7 +3,7 @@ namespace Friendica\Testsrc\Model\User; use Friendica\App\BaseURL; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Model\User\Cookie; use Friendica\Test\DatabaseTest; use Friendica\Test\Util\StaticCookie; @@ -11,7 +11,7 @@ use Mockery\MockInterface; class CookieTest extends DatabaseTest { - /** @var MockInterface|IConfiguration */ + /** @var MockInterface|IConfig */ private $config; /** @var MockInterface|BaseURL */ private $baseUrl; @@ -22,7 +22,7 @@ class CookieTest extends DatabaseTest parent::setUp(); - $this->config = \Mockery::mock(IConfiguration::class); + $this->config = \Mockery::mock(IConfig::class); $this->baseUrl = \Mockery::mock(BaseURL::class); } diff --git a/tests/src/Util/BaseURLTest.php b/tests/src/Util/BaseURLTest.php index 47f80f36ea..12fcf8858b 100644 --- a/tests/src/Util/BaseURLTest.php +++ b/tests/src/Util/BaseURLTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Util; use Friendica\App\BaseURL; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Test\MockedTest; class BaseURLTest extends MockedTest @@ -173,7 +173,7 @@ class BaseURLTest extends MockedTest */ public function testCheck($server, $input, $assert) { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']); $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']); $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']); @@ -295,7 +295,7 @@ class BaseURLTest extends MockedTest */ public function testSave($input, $save, $url) { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']); $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']); $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']); @@ -333,7 +333,7 @@ class BaseURLTest extends MockedTest */ public function testSaveByUrl($input, $save, $url) { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']); $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']); $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']); @@ -409,7 +409,7 @@ class BaseURLTest extends MockedTest */ public function testGetURL($sslPolicy, $ssl, $url, $assert) { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local'); $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test'); $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy); @@ -467,7 +467,7 @@ class BaseURLTest extends MockedTest */ public function testCheckRedirectHTTPS($server, $forceSSL, $sslPolicy, $url, $redirect) { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local'); $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test'); $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy); @@ -503,7 +503,7 @@ class BaseURLTest extends MockedTest */ public function testWrongSave($fail) { - $configMock = \Mockery::mock(IConfiguration::class); + $configMock = \Mockery::mock(IConfig::class); $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local'); $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test'); $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn(BaseURL::DEFAULT_SSL_SCHEME); diff --git a/tests/src/Util/ProfilerTest.php b/tests/src/Util/ProfilerTest.php index ba47858a09..400d557c34 100644 --- a/tests/src/Util/ProfilerTest.php +++ b/tests/src/Util/ProfilerTest.php @@ -3,7 +3,7 @@ namespace Friendica\Test\src\Util; use Friendica\Core\Config\Cache\ConfigCache; -use Friendica\Core\Config\IConfiguration; +use Friendica\Core\Config\IConfig; use Friendica\Test\MockedTest; use Friendica\Util\Profiler; use Mockery\MockInterface; @@ -235,7 +235,7 @@ class ProfilerTest extends MockedTest $profiler->saveTimestamp(time(), 'network', 'test1'); - $config = \Mockery::mock(IConfiguration::class); + $config = \Mockery::mock(IConfig::class); $config->shouldReceive('get') ->with('system', 'profiler') ->andReturn(false)