$a->runFrontend(
$dice->create(\Friendica\App\Module::class),
$dice->create(\Friendica\App\Router::class),
- $dice->create(\Friendica\Core\Config\IPConfiguration::class),
+ $dice->create(\Friendica\Core\PConfig\IPConfig::class),
$dice->create(\Friendica\App\Authentication::class),
$dice->create(\Friendica\App\Page::class)
);
use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\App\Authentication;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
-use Friendica\Core\Config\IPConfiguration;
+use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Theme;
private $process;
/**
- * @var IPConfiguration
+ * @var IPConfig
*/
private $pConfig;
/**
* Returns the current config cache of this node
*
- * @return ConfigCache
+ * @return Cache
*/
public function getConfigCache()
{
* @param L10n $l10n The translator instance
* @param App\Arguments $args The Friendica Arguments of the call
* @param Core\Process $process The process methods
- * @param IPConfiguration $pConfig Personal configuration
+ * @param IPConfig $pConfig Personal configuration
*/
- 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)
+ public function __construct(Database $database, IConfig $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfig $pConfig)
{
$this->database = $database;
$this->config = $config;
*
* @param App\Module $module The determined module
* @param App\Router $router
- * @param IPConfiguration $pconfig
+ * @param IPConfig $pconfig
* @param Authentication $auth The Authentication backend of the node
- * @param App\Page $page The Friendica page printing container
+ * @param App\Page $page The Friendica page printing container
+ *
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- public function runFrontend(App\Module $module, App\Router $router, IPConfiguration $pconfig, Authentication $auth, App\Page $page)
+ public function runFrontend(App\Module $module, App\Router $router, IPConfig $pconfig, Authentication $auth, App\Page $page)
{
$moduleName = $module->getName();
use Exception;
use Friendica\App;
use Friendica\Core\Config\IConfig;
-use Friendica\Core\Config\IPConfiguration;
+use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\Hook;
use Friendica\Core\Session;
use Friendica\Core\System;
private $cookie;
/** @var Session\ISession */
private $session;
- /** @var IPConfiguration */
+ /** @var IPConfig */
private $pConfig;
/**
* @param LoggerInterface $logger
* @param User\Cookie $cookie
* @param Session\ISession $session
- * @param IPConfiguration $pConfig
+ * @param IPConfig $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)
+ public function __construct(IConfig $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfig $pConfig)
{
$this->config = $config;
$this->mode = $mode;
namespace Friendica\App;
use Detection\MobileDetect;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Database\Database;
use Friendica\Util\BasePath;
*
* @throws \Exception
*/
- public function determine(BasePath $basepath, Database $database, ConfigCache $configCache)
+ public function determine(BasePath $basepath, Database $database, Cache $configCache)
{
$mode = 0;
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Core\Config\IConfig;
-use Friendica\Core\Config\IPConfiguration;
+use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
* - 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 IConfig $config The Friendica configuration
- * @param IPConfiguration $pConfig The Friendica personal configuration (for user)
+ * @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 IPConfig $pConfig The Friendica personal configuration (for user)
*
* @throws HTTPException\InternalServerErrorException
*/
- private function initHead(App $app, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pConfig)
+ private function initHead(App $app, Module $module, L10n $l10n, IConfig $config, IPConfig $pConfig)
{
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
/**
* 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 IConfig $config The Configuration of this node
- * @param IPConfiguration $pconfig The personal/user configuration
+ * @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 IPConfig $pconfig The personal/user configuration
*
* @throws HTTPException\InternalServerErrorException
*/
- public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pconfig)
+ public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfig $pconfig)
{
$moduleName = $module->getName();
*/
private $appMode;
/**
- * @var Config\Cache\ConfigCache
+ * @var \Friendica\Core\Config\Cache
*/
private $configCache;
HELP;
}
- public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfig $config, Database $dba, array $argv = null)
+ public function __construct(App\Mode $appMode, Config\Cache $configCache, Config\IConfig $config, Database $dba, array $argv = null)
{
parent::__construct($argv);
}
/**
- * @param Installer $installer The Installer instance
- * @param Config\Cache\ConfigCache $configCache The config cache
+ * @param Installer $installer The Installer instance
+ * @param \Friendica\Core\Config\Cache $configCache The config cache
*
* @return bool true if checks were successfully, otherwise false
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- private function runBasicChecks(Installer $installer, Config\Cache\ConfigCache $configCache)
+ private function runBasicChecks(Installer $installer, Config\Cache $configCache)
{
$checked = true;
namespace Friendica\Console;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Update;
use Friendica\Database\Database;
use Friendica\Database\DBStructure;
*/
private $dba;
/**
- * @var ConfigCache
+ * @var Cache
*/
private $configCache;
return $help;
}
- public function __construct(Database $dba, ConfigCache $configCache, $argv = null)
+ public function __construct(Database $dba, Cache $configCache, $argv = null)
{
parent::__construct($argv);
abstract class BaseConfig implements IConfig
{
/**
- * @var Cache\ConfigCache
+ * @var Cache
*/
protected $configCache;
protected $configModel;
/**
- * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
- * @param Model\Config\Config $configModel The configuration model
+ * @param Cache $configCache The configuration cache (based on the config-files)
+ * @param Model\Config\Config $configModel The configuration model
*/
- public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
+ public function __construct(Cache $configCache, Model\Config\Config $configModel)
{
$this->configCache = $configCache;
$this->configModel = $configModel;
--- /dev/null
+<?php
+
+namespace Friendica\Core;
+
+use Friendica\Core\PConfig\Cache;
+use Friendica\Core\PConfig\IPConfig;
+use Friendica\Model;
+
+/**
+ * This class is responsible for the user-specific configuration values in Friendica
+ * The values are set through the Config-DB-Table (per Config-DB-model @see Model\Config\PConfig)
+ *
+ * The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
+ * increase the performance.
+ */
+abstract class BasePConfig implements IPConfig
+{
+ /**
+ * @var Cache
+ */
+ protected $configCache;
+
+ /**
+ * @var Model\Config\PConfig
+ */
+ protected $configModel;
+
+ /**
+ * @param Cache $configCache The configuration cache
+ * @param Model\Config\PConfig $configModel The configuration model
+ */
+ public function __construct(Cache $configCache, Model\Config\PConfig $configModel)
+ {
+ $this->configCache = $configCache;
+ $this->configModel = $configModel;
+ }
+
+ /**
+ * Returns the Config Cache
+ *
+ * @return Cache
+ */
+ public function getCache()
+ {
+ return $this->configCache;
+ }
+}
--- /dev/null
+<?php
+
+namespace Friendica\Core\Config;
+
+use ParagonIE\HiddenString\HiddenString;
+
+/**
+ * The Friendica config cache for the application
+ * Initial, all *.config.php files are loaded into this cache with the
+ * ConfigFileLoader ( @see ConfigFileLoader )
+ */
+class Cache
+{
+ /**
+ * @var array
+ */
+ private $config;
+
+ /**
+ * @var bool
+ */
+ private $hidePasswordOutput;
+
+ /**
+ * @param array $config A initial config array
+ * @param bool $hidePasswordOutput True, if cache variables should take extra care of password values
+ */
+ public function __construct(array $config = [], bool $hidePasswordOutput = true)
+ {
+ $this->hidePasswordOutput = $hidePasswordOutput;
+ $this->load($config);
+ }
+
+ /**
+ * Tries to load the specified configuration array into the config array.
+ * Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
+ *
+ * @param array $config
+ * @param bool $overwrite Force value overwrite if the config key already exists
+ */
+ public function load(array $config, bool $overwrite = false)
+ {
+ $categories = array_keys($config);
+
+ foreach ($categories as $category) {
+ if (is_array($config[$category])) {
+ $keys = array_keys($config[$category]);
+
+ foreach ($keys as $key) {
+ $value = $config[$category][$key];
+ if (isset($value)) {
+ if ($overwrite) {
+ $this->set($category, $key, $value);
+ } else {
+ $this->setDefault($category, $key, $value);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets a value from the config cache.
+ *
+ * @param string $cat Config category
+ * @param string $key Config key
+ *
+ * @return null|mixed Returns the value of the Config entry or null if not set
+ */
+ public function get(string $cat, string $key = null)
+ {
+ if (isset($this->config[$cat][$key])) {
+ return $this->config[$cat][$key];
+ } elseif (!isset($key) && isset($this->config[$cat])) {
+ return $this->config[$cat];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Sets a default value in the config cache. Ignores already existing keys.
+ *
+ * @param string $cat Config category
+ * @param string $key Config key
+ * @param mixed $value Default value to set
+ */
+ private function setDefault(string $cat, string $key, $value)
+ {
+ if (!isset($this->config[$cat][$key])) {
+ $this->set($cat, $key, $value);
+ }
+ }
+
+ /**
+ * Sets a value in the config cache. Accepts raw output from the config table
+ *
+ * @param string $cat Config category
+ * @param string $key Config key
+ * @param mixed $value Value to set
+ *
+ * @return bool True, if the value is set
+ */
+ public function set(string $cat, string $key, $value)
+ {
+ if (!isset($this->config[$cat])) {
+ $this->config[$cat] = [];
+ }
+
+ if ($this->hidePasswordOutput &&
+ $key == 'password' &&
+ is_string($value)) {
+ $this->config[$cat][$key] = new HiddenString((string)$value);
+ } else {
+ $this->config[$cat][$key] = $value;
+ }
+ return true;
+ }
+
+ /**
+ * Deletes a value from the config cache.
+ *
+ * @param string $cat Config category
+ * @param string $key Config key
+ *
+ * @return bool true, if deleted
+ */
+ public function delete(string $cat, string $key)
+ {
+ if (isset($this->config[$cat][$key])) {
+ unset($this->config[$cat][$key]);
+ if (count($this->config[$cat]) == 0) {
+ unset($this->config[$cat]);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the whole configuration
+ *
+ * @return array The configuration
+ */
+ public function getAll()
+ {
+ return $this->config;
+ }
+
+ /**
+ * Returns an array with missing categories/Keys
+ *
+ * @param array $config The array to check
+ *
+ * @return array
+ */
+ public function keyDiff(array $config)
+ {
+ $return = [];
+
+ $categories = array_keys($config);
+
+ foreach ($categories as $category) {
+ if (is_array($config[$category])) {
+ $keys = array_keys($config[$category]);
+
+ foreach ($keys as $key) {
+ if (!isset($this->config[$category][$key])) {
+ $return[$category][$key] = $config[$category][$key];
+ }
+ }
+ }
+ }
+
+ return $return;
+ }
+}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config\Cache;
-
-use ParagonIE\HiddenString\HiddenString;
-
-/**
- * The Friendica config cache for the application
- * Initial, all *.config.php files are loaded into this cache with the
- * ConfigFileLoader ( @see ConfigFileLoader )
- */
-class ConfigCache
-{
- /**
- * @var array
- */
- private $config;
-
- /**
- * @var bool
- */
- private $hidePasswordOutput;
-
- /**
- * @param array $config A initial config array
- * @param bool $hidePasswordOutput True, if cache variables should take extra care of password values
- */
- public function __construct(array $config = [], bool $hidePasswordOutput = true)
- {
- $this->hidePasswordOutput = $hidePasswordOutput;
- $this->load($config);
- }
-
- /**
- * Tries to load the specified configuration array into the config array.
- * Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
- *
- * @param array $config
- * @param bool $overwrite Force value overwrite if the config key already exists
- */
- public function load(array $config, bool $overwrite = false)
- {
- $categories = array_keys($config);
-
- foreach ($categories as $category) {
- if (is_array($config[$category])) {
- $keys = array_keys($config[$category]);
-
- foreach ($keys as $key) {
- $value = $config[$category][$key];
- if (isset($value)) {
- if ($overwrite) {
- $this->set($category, $key, $value);
- } else {
- $this->setDefault($category, $key, $value);
- }
- }
- }
- }
- }
- }
-
- /**
- * Gets a value from the config cache.
- *
- * @param string $cat Config category
- * @param string $key Config key
- *
- * @return null|mixed Returns the value of the Config entry or null if not set
- */
- public function get(string $cat, string $key = null)
- {
- if (isset($this->config[$cat][$key])) {
- return $this->config[$cat][$key];
- } elseif (!isset($key) && isset($this->config[$cat])) {
- return $this->config[$cat];
- } else {
- return null;
- }
- }
-
- /**
- * Sets a default value in the config cache. Ignores already existing keys.
- *
- * @param string $cat Config category
- * @param string $key Config key
- * @param mixed $value Default value to set
- */
- private function setDefault(string $cat, string $key, $value)
- {
- if (!isset($this->config[$cat][$key])) {
- $this->set($cat, $key, $value);
- }
- }
-
- /**
- * Sets a value in the config cache. Accepts raw output from the config table
- *
- * @param string $cat Config category
- * @param string $key Config key
- * @param mixed $value Value to set
- *
- * @return bool True, if the value is set
- */
- public function set(string $cat, string $key, $value)
- {
- if (!isset($this->config[$cat])) {
- $this->config[$cat] = [];
- }
-
- if ($this->hidePasswordOutput &&
- $key == 'password' &&
- is_string($value)) {
- $this->config[$cat][$key] = new HiddenString((string)$value);
- } else {
- $this->config[$cat][$key] = $value;
- }
- return true;
- }
-
- /**
- * Deletes a value from the config cache.
- *
- * @param string $cat Config category
- * @param string $key Config key
- *
- * @return bool true, if deleted
- */
- public function delete(string $cat, string $key)
- {
- if (isset($this->config[$cat][$key])) {
- unset($this->config[$cat][$key]);
- if (count($this->config[$cat]) == 0) {
- unset($this->config[$cat]);
- }
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Returns the whole configuration
- *
- * @return array The configuration
- */
- public function getAll()
- {
- return $this->config;
- }
-
- /**
- * Returns an array with missing categories/Keys
- *
- * @param array $config The array to check
- *
- * @return array
- */
- public function keyDiff(array $config)
- {
- $return = [];
-
- $categories = array_keys($config);
-
- foreach ($categories as $category) {
- if (is_array($config[$category])) {
- $keys = array_keys($config[$category]);
-
- foreach ($keys as $key) {
- if (!isset($this->config[$category][$key])) {
- $return[$category][$key] = $config[$category][$key];
- }
- }
- }
- }
-
- return $return;
- }
-}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config\Cache;
-
-use ParagonIE\HiddenString\HiddenString;
-
-/**
- * The Friendica config cache for users
- */
-class PConfigCache
-{
- /**
- * @var array
- */
- private $config;
-
- /**
- * @var bool
- */
- private $hidePasswordOutput;
-
- /**
- * @param bool $hidePasswordOutput True, if cache variables should take extra care of password values
- */
- public function __construct(bool $hidePasswordOutput = true)
- {
- $this->hidePasswordOutput = $hidePasswordOutput;
- }
-
- /**
- * Tries to load the specified configuration array into the user specific config array.
- * Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
- *
- * @param int $uid
- * @param array $config
- */
- public function load($uid, array $config)
- {
- if (!is_int($uid)) {
- return;
- }
-
- $categories = array_keys($config);
-
- foreach ($categories as $category) {
- if (isset($config[$category]) && is_array($config[$category])) {
-
- $keys = array_keys($config[$category]);
-
- foreach ($keys as $key) {
- $value = $config[$category][$key];
- if (isset($value)) {
- $this->set($uid, $category, $key, $value);
- }
- }
- }
- }
- }
-
- /**
- * Retrieves a value from the user config cache
- *
- * @param int $uid User Id
- * @param string $cat Config category
- * @param string $key Config key
- *
- * @return null|string The value of the config entry or null if not set
- */
- public function get($uid, string $cat, string $key = null)
- {
- if (!is_int($uid)) {
- return null;
- }
-
- if (isset($this->config[$uid][$cat][$key])) {
- return $this->config[$uid][$cat][$key];
- } elseif (!isset($key) && isset($this->config[$uid][$cat])) {
- return $this->config[$uid][$cat];
- } else {
- return null;
- }
- }
-
- /**
- * Sets a value in the user config cache
- *
- * Accepts raw output from the pconfig table
- *
- * @param int $uid User Id
- * @param string $cat Config category
- * @param string $key Config key
- * @param mixed $value Value to set
- *
- * @return bool Set successful
- */
- public function set($uid, string $cat, string $key, $value)
- {
- if (!is_int($uid)) {
- return false;
- }
-
- if (!isset($this->config[$uid]) || !is_array($this->config[$uid])) {
- $this->config[$uid] = [];
- }
-
- if (!isset($this->config[$uid][$cat])) {
- $this->config[$uid][$cat] = [];
- }
-
- if ($this->hidePasswordOutput &&
- $key == 'password' &&
- !empty($value) && is_string($value)) {
- $this->config[$uid][$cat][$key] = new HiddenString((string)$value);
- } else {
- $this->config[$uid][$cat][$key] = $value;
- }
-
-
- return true;
- }
-
- /**
- * Deletes a value from the user config cache
- *
- * @param int $uid User Id
- * @param string $cat Config category
- * @param string $key Config key
- *
- * @return bool true, if deleted
- */
- public function delete($uid, string $cat, string $key)
- {
- if (!is_int($uid)) {
- return false;
- }
-
- if (isset($this->config[$uid][$cat][$key])) {
- unset($this->config[$uid][$cat][$key]);
- if (count($this->config[$uid][$cat]) == 0) {
- unset($this->config[$uid][$cat]);
- if (count($this->config[$uid]) == 0) {
- unset($this->config[$uid]);
- }
- }
-
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Returns the whole configuration
- *
- * @return array The configuration
- */
- public function getAll()
- {
- return $this->config;
- }
-
- /**
- * Returns an array with missing categories/Keys
- *
- * @param array $config The array to check
- *
- * @return array
- */
- public function keyDiff(array $config)
- {
- $return = [];
-
- $categories = array_keys($config);
-
- foreach ($categories as $category) {
- if (is_array($config[$category])) {
- $keys = array_keys($config[$category]);
-
- foreach ($keys as $key) {
- if (!isset($this->config[$category][$key])) {
- $return[$category][$key] = $config[$category][$key];
- }
- }
- }
- }
-
- return $return;
- }
-}
/**
* Loads all configuration values of family into a cached storage.
*
- * All configuration values of the system are stored in the cache ( @see ConfigCache )
- *
- * @param string $cat The category of the configuration value
+ * All configuration values of the system are stored in the cache ( @param string $cat The category of the configuration value
*
* @return void
*/
/**
* Returns the Config Cache
*
- * @return Cache\ConfigCache
+ * @return Cache
*/
function getCache();
}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-/**
- * Interface for accessing user specific configurations
- */
-interface IPConfiguration
-{
-
- /**
- * Loads all configuration values of a user's config family into a cached storage.
- *
- * All configuration values of the given user are stored with the $uid in the cache
- *
- * @param int $uid The user_id
- * @param string $cat The category of the configuration value
- *
- * @return void
- * @see PConfigCache
- *
- */
- function load(int $uid, string $cat = 'config');
-
- /**
- * Get a particular user's config variable given the category name
- * ($cat) and a key.
- *
- * Get a particular user's config value from the given category ($cat)
- * and the $key with the $uid from a cached storage either from the $this->configAdapter
- * (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
- *
- * @param int $uid The user_id
- * @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(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
-
- /**
- * Sets a configuration value for a user
- *
- * Stores a config value ($value) in the category ($family) under the key ($key)
- * for the user_id $uid.
- *
- * @note Please do not store booleans - convert to 0/1 integer values!
- *
- * @param int $uid The user_id
- * @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(int $uid, string $cat, string $key, $value);
-
- /**
- * Deletes the given key from the users's configuration.
- *
- * Removes the configured value from the stored cache in $this->configCache
- * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
- * with the given $uid.
- *
- * @param int $uid The user_id
- * @param string $cat The category of the configuration value
- * @param string $key The configuration key to delete
- *
- * @return bool
- */
- function delete(int $uid, string $cat, string $key);
-
-
- /**
- * Returns the Config Cache
- *
- * @return Cache\PConfigCache
- */
- function getCache();
-}
private $db_loaded;
/**
- * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
+ * @param Cache $configCache The configuration cache (based on the config-files)
* @param Model\Config\Config $configModel The configuration model
*/
- public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
+ public function __construct(Cache $configCache, Model\Config\Config $configModel)
{
parent::__construct($configCache, $configModel);
$this->db_loaded = [];
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-use Friendica\Model;
-
-/**
- * This class implements the Just-In-Time configuration, which will cache
- * user config values in a cache, once they are retrieved.
- *
- * Default Configuration type.
- * Provides the best performance for pages loading few configuration variables.
- */
-class JitPConfiguration extends PConfiguration
-{
- /**
- * @var array Array of already loaded db values (even if there was no value)
- */
- private $db_loaded;
-
- /**
- * @param Cache\PConfigCache $configCache The configuration cache
- * @param Model\Config\PConfig $configModel The configuration model
- */
- public function __construct(Cache\PConfigCache $configCache, Model\Config\PConfig $configModel)
- {
- parent::__construct($configCache, $configModel);
- $this->db_loaded = [];
- }
-
- /**
- * {@inheritDoc}
- *
- */
- public function load(int $uid, string $cat = 'config')
- {
- // If not connected or no uid, do nothing
- if (!$uid || !$this->configModel->isConnected()) {
- return;
- }
-
- $config = $this->configModel->load($uid, $cat);
-
- if (!empty($config[$cat])) {
- foreach ($config[$cat] as $key => $value) {
- $this->db_loaded[$uid][$cat][$key] = true;
- }
- }
-
- // load the whole category out of the DB into the cache
- $this->configCache->load($uid, $config);
- }
-
- /**
- * {@inheritDoc}
- */
- public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
- {
- if (!$uid) {
- return $default_value;
- }
-
- // if the value isn't loaded or refresh is needed, load it to the cache
- if ($this->configModel->isConnected() &&
- (empty($this->db_loaded[$uid][$cat][$key]) ||
- $refresh)) {
-
- $dbvalue = $this->configModel->get($uid, $cat, $key);
-
- if (isset($dbvalue)) {
- $this->configCache->set($uid, $cat, $key, $dbvalue);
- unset($dbvalue);
- }
-
- $this->db_loaded[$uid][$cat][$key] = true;
- }
-
- // use the config cache for return
- $result = $this->configCache->get($uid, $cat, $key);
-
- return (isset($result)) ? $result : $default_value;
- }
-
- /**
- * {@inheritDoc}
- */
- public function set(int $uid, string $cat, string $key, $value)
- {
- if (!$uid) {
- return false;
- }
-
- // set the cache first
- $cached = $this->configCache->set($uid, $cat, $key, $value);
-
- // If there is no connected adapter, we're finished
- if (!$this->configModel->isConnected()) {
- return $cached;
- }
-
- $stored = $this->configModel->set($uid, $cat, $key, $value);
-
- $this->db_loaded[$uid][$cat][$key] = $stored;
-
- return $cached && $stored;
- }
-
- /**
- * {@inheritDoc}
- */
- public function delete(int $uid, string $cat, string $key)
- {
- if (!$uid) {
- return false;
- }
-
- $cacheRemoved = $this->configCache->delete($uid, $cat, $key);
-
- if (isset($this->db_loaded[$uid][$cat][$key])) {
- unset($this->db_loaded[$uid][$cat][$key]);
- }
-
- if (!$this->configModel->isConnected()) {
- return $cacheRemoved;
- }
-
- $storeRemoved = $this->configModel->delete($uid, $cat, $key);
-
- return $cacheRemoved || $storeRemoved;
- }
-}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-use Friendica\Model;
-
-/**
- * This class is responsible for the user-specific configuration values in Friendica
- * The values are set through the Config-DB-Table (per Config-DB-model @see Model\Config\PConfig)
- *
- * The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
- * increase the performance.
- */
-abstract class PConfiguration implements IPConfiguration
-{
- /**
- * @var Cache\PConfigCache
- */
- protected $configCache;
-
- /**
- * @var Model\Config\PConfig
- */
- protected $configModel;
-
- /**
- * @param Cache\PConfigCache $configCache The configuration cache
- * @param Model\Config\PConfig $configModel The configuration model
- */
- public function __construct(Cache\PConfigCache $configCache, Model\Config\PConfig $configModel)
- {
- $this->configCache = $configCache;
- $this->configModel = $configModel;
- }
-
- /**
- * Returns the Config Cache
- *
- * @return Cache\PConfigCache
- */
- public function getCache()
- {
- return $this->configCache;
- }
-}
private $config_loaded;
/**
- * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
+ * @param Cache $configCache The configuration cache (based on the config-files)
* @param Model\Config\Config $configModel The configuration model
*/
- public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
+ public function __construct(Cache $configCache, Model\Config\Config $configModel)
{
parent::__construct($configCache, $configModel);
$this->config_loaded = false;
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-use Friendica\Model;
-
-/**
- * This class implements the preload configuration, which will cache
- * all user config values per call in a cache.
- *
- * Minimizes the number of database queries to retrieve configuration values at the cost of memory.
- */
-class PreloadPConfiguration extends PConfiguration
-{
- /** @var array */
- private $config_loaded;
-
- /**
- * @param Cache\PConfigCache $configCache The configuration cache
- * @param Model\Config\PConfig $configModel The configuration model
- */
- public function __construct(Cache\PConfigCache $configCache, Model\Config\PConfig $configModel)
- {
- parent::__construct($configCache, $configModel);
- $this->config_loaded = [];
- }
-
- /**
- * {@inheritDoc}
- *
- * This loads all config values everytime load is called
- *
- */
- public function load(int $uid, string $cat = 'config')
- {
- // Don't load the whole configuration twice or with invalid uid
- if (!$uid || !empty($this->config_loaded[$uid])) {
- return;
- }
-
- // If not connected, do nothing
- if (!$this->configModel->isConnected()) {
- return;
- }
-
- $config = $this->configModel->load($uid);
- $this->config_loaded[$uid] = true;
-
- // load the whole category out of the DB into the cache
- $this->configCache->load($uid, $config);
- }
-
- /**
- * {@inheritDoc}
- */
- public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
- {
- if (!$uid) {
- return $default_value;
- }
-
- if (empty($this->config_loaded[$uid])) {
- $this->load($uid);
- } elseif ($refresh) {
- if ($this->configModel->isConnected()) {
- $config = $this->configModel->get($uid, $cat, $key);
- if (isset($config)) {
- $this->configCache->set($uid, $cat, $key, $config);
- }
- }
- }
-
- // use the config cache for return
- $result = $this->configCache->get($uid, $cat, $key);
-
- return (isset($result)) ? $result : $default_value;
- }
-
- /**
- * {@inheritDoc}
- */
- public function set(int $uid, string $cat, string $key, $value)
- {
- if (!$uid) {
- return false;
- }
-
- if (empty($this->config_loaded[$uid])) {
- $this->load($uid);
- }
-
- // set the cache first
- $cached = $this->configCache->set($uid, $cat, $key, $value);
-
- // If there is no connected adapter, we're finished
- if (!$this->configModel->isConnected()) {
- return $cached;
- }
-
- $stored = $this->configModel->set($uid, $cat, $key, $value);
-
- return $cached && $stored;
- }
-
- /**
- * {@inheritDoc}
- */
- public function delete(int $uid, string $cat, string $key)
- {
- if (!$uid) {
- return false;
- }
-
- if (empty($this->config_loaded[$uid])) {
- $this->load($uid);
- }
-
- $cacheRemoved = $this->configCache->delete($uid, $cat, $key);
-
- if (!$this->configModel->isConnected()) {
- return $cacheRemoved;
- }
-
- $storeRemoved = $this->configModel->delete($uid, $cat, $key);
-
- return $cacheRemoved || $storeRemoved;
- }
-}
use DOMDocument;
use Exception;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Database\Database;
use Friendica\Database\DBStructure;
use Friendica\DI;
* - Creates `config/local.config.php`
* - Installs Database Structure
*
- * @param ConfigCache $configCache The config cache with all config relevant information
+ * @param Cache $configCache The config cache with all config relevant information
*
* @return bool true if the config was created, otherwise false
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function createConfig(ConfigCache $configCache)
+ public function createConfig(Cache $configCache)
{
$basepath = $configCache->get('system', 'basepath');
/**
* Setup the default cache for a new installation
*
- * @param ConfigCache $configCache The configuration cache
- * @param string $basePath The determined basepath
+ * @param Cache $configCache The configuration cache
+ * @param string $basePath The determined basepath
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function setUpCache(ConfigCache $configCache, $basePath)
+ public function setUpCache(Cache $configCache, $basePath)
{
$configCache->set('config', 'php_path' , $this->getPHPPath());
$configCache->set('system', 'basepath' , $basePath);
--- /dev/null
+<?php
+
+namespace Friendica\Core\PConfig;
+
+use ParagonIE\HiddenString\HiddenString;
+
+/**
+ * The Friendica config cache for users
+ */
+class Cache
+{
+ /**
+ * @var array
+ */
+ private $config;
+
+ /**
+ * @var bool
+ */
+ private $hidePasswordOutput;
+
+ /**
+ * @param bool $hidePasswordOutput True, if cache variables should take extra care of password values
+ */
+ public function __construct(bool $hidePasswordOutput = true)
+ {
+ $this->hidePasswordOutput = $hidePasswordOutput;
+ }
+
+ /**
+ * Tries to load the specified configuration array into the user specific config array.
+ * Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
+ *
+ * @param int $uid
+ * @param array $config
+ */
+ public function load($uid, array $config)
+ {
+ if (!is_int($uid)) {
+ return;
+ }
+
+ $categories = array_keys($config);
+
+ foreach ($categories as $category) {
+ if (isset($config[$category]) && is_array($config[$category])) {
+
+ $keys = array_keys($config[$category]);
+
+ foreach ($keys as $key) {
+ $value = $config[$category][$key];
+ if (isset($value)) {
+ $this->set($uid, $category, $key, $value);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Retrieves a value from the user config cache
+ *
+ * @param int $uid User Id
+ * @param string $cat Config category
+ * @param string $key Config key
+ *
+ * @return null|string The value of the config entry or null if not set
+ */
+ public function get($uid, string $cat, string $key = null)
+ {
+ if (!is_int($uid)) {
+ return null;
+ }
+
+ if (isset($this->config[$uid][$cat][$key])) {
+ return $this->config[$uid][$cat][$key];
+ } elseif (!isset($key) && isset($this->config[$uid][$cat])) {
+ return $this->config[$uid][$cat];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Sets a value in the user config cache
+ *
+ * Accepts raw output from the pconfig table
+ *
+ * @param int $uid User Id
+ * @param string $cat Config category
+ * @param string $key Config key
+ * @param mixed $value Value to set
+ *
+ * @return bool Set successful
+ */
+ public function set($uid, string $cat, string $key, $value)
+ {
+ if (!is_int($uid)) {
+ return false;
+ }
+
+ if (!isset($this->config[$uid]) || !is_array($this->config[$uid])) {
+ $this->config[$uid] = [];
+ }
+
+ if (!isset($this->config[$uid][$cat])) {
+ $this->config[$uid][$cat] = [];
+ }
+
+ if ($this->hidePasswordOutput &&
+ $key == 'password' &&
+ !empty($value) && is_string($value)) {
+ $this->config[$uid][$cat][$key] = new HiddenString((string)$value);
+ } else {
+ $this->config[$uid][$cat][$key] = $value;
+ }
+
+
+ return true;
+ }
+
+ /**
+ * Deletes a value from the user config cache
+ *
+ * @param int $uid User Id
+ * @param string $cat Config category
+ * @param string $key Config key
+ *
+ * @return bool true, if deleted
+ */
+ public function delete($uid, string $cat, string $key)
+ {
+ if (!is_int($uid)) {
+ return false;
+ }
+
+ if (isset($this->config[$uid][$cat][$key])) {
+ unset($this->config[$uid][$cat][$key]);
+ if (count($this->config[$uid][$cat]) == 0) {
+ unset($this->config[$uid][$cat]);
+ if (count($this->config[$uid]) == 0) {
+ unset($this->config[$uid]);
+ }
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the whole configuration
+ *
+ * @return array The configuration
+ */
+ public function getAll()
+ {
+ return $this->config;
+ }
+
+ /**
+ * Returns an array with missing categories/Keys
+ *
+ * @param array $config The array to check
+ *
+ * @return array
+ */
+ public function keyDiff(array $config)
+ {
+ $return = [];
+
+ $categories = array_keys($config);
+
+ foreach ($categories as $category) {
+ if (is_array($config[$category])) {
+ $keys = array_keys($config[$category]);
+
+ foreach ($keys as $key) {
+ if (!isset($this->config[$category][$key])) {
+ $return[$category][$key] = $config[$category][$key];
+ }
+ }
+ }
+ }
+
+ return $return;
+ }
+}
--- /dev/null
+<?php
+
+namespace Friendica\Core\PConfig;
+
+/**
+ * Interface for accessing user specific configurations
+ */
+interface IPConfig
+{
+
+ /**
+ * Loads all configuration values of a user's config family into a cached storage.
+ *
+ * All configuration values of the given user are stored with the $uid in the cache
+ *
+ * @param int $uid The user_id
+ * @param string $cat The category of the configuration value
+ *
+ * @return void
+ * @see Cache
+ *
+ */
+ function load(int $uid, string $cat = 'config');
+
+ /**
+ * Get a particular user's config variable given the category name
+ * ($cat) and a key.
+ *
+ * Get a particular user's config value from the given category ($cat)
+ * and the $key with the $uid from a cached storage either from the $this->configAdapter
+ * (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
+ *
+ * @param int $uid The user_id
+ * @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(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
+
+ /**
+ * Sets a configuration value for a user
+ *
+ * Stores a config value ($value) in the category ($family) under the key ($key)
+ * for the user_id $uid.
+ *
+ * @note Please do not store booleans - convert to 0/1 integer values!
+ *
+ * @param int $uid The user_id
+ * @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(int $uid, string $cat, string $key, $value);
+
+ /**
+ * Deletes the given key from the users's configuration.
+ *
+ * Removes the configured value from the stored cache in $this->configCache
+ * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
+ * with the given $uid.
+ *
+ * @param int $uid The user_id
+ * @param string $cat The category of the configuration value
+ * @param string $key The configuration key to delete
+ *
+ * @return bool
+ */
+ function delete(int $uid, string $cat, string $key);
+
+
+ /**
+ * Returns the Config Cache
+ *
+ * @return Cache
+ */
+ function getCache();
+}
--- /dev/null
+<?php
+
+namespace Friendica\Core\PConfig;
+
+use Friendica\Core\BasePConfig;
+use Friendica\Model;
+
+/**
+ * This class implements the Just-In-Time configuration, which will cache
+ * user config values in a cache, once they are retrieved.
+ *
+ * Default Configuration type.
+ * Provides the best performance for pages loading few configuration variables.
+ */
+class JitPConfig extends BasePConfig
+{
+ /**
+ * @var array Array of already loaded db values (even if there was no value)
+ */
+ private $db_loaded;
+
+ /**
+ * @param Cache $configCache The configuration cache
+ * @param Model\Config\PConfig $configModel The configuration model
+ */
+ public function __construct(Cache $configCache, Model\Config\PConfig $configModel)
+ {
+ parent::__construct($configCache, $configModel);
+ $this->db_loaded = [];
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ */
+ public function load(int $uid, string $cat = 'config')
+ {
+ // If not connected or no uid, do nothing
+ if (!$uid || !$this->configModel->isConnected()) {
+ return;
+ }
+
+ $config = $this->configModel->load($uid, $cat);
+
+ if (!empty($config[$cat])) {
+ foreach ($config[$cat] as $key => $value) {
+ $this->db_loaded[$uid][$cat][$key] = true;
+ }
+ }
+
+ // load the whole category out of the DB into the cache
+ $this->configCache->load($uid, $config);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
+ {
+ if (!$uid) {
+ return $default_value;
+ }
+
+ // if the value isn't loaded or refresh is needed, load it to the cache
+ if ($this->configModel->isConnected() &&
+ (empty($this->db_loaded[$uid][$cat][$key]) ||
+ $refresh)) {
+
+ $dbvalue = $this->configModel->get($uid, $cat, $key);
+
+ if (isset($dbvalue)) {
+ $this->configCache->set($uid, $cat, $key, $dbvalue);
+ unset($dbvalue);
+ }
+
+ $this->db_loaded[$uid][$cat][$key] = true;
+ }
+
+ // use the config cache for return
+ $result = $this->configCache->get($uid, $cat, $key);
+
+ return (isset($result)) ? $result : $default_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function set(int $uid, string $cat, string $key, $value)
+ {
+ if (!$uid) {
+ return false;
+ }
+
+ // set the cache first
+ $cached = $this->configCache->set($uid, $cat, $key, $value);
+
+ // If there is no connected adapter, we're finished
+ if (!$this->configModel->isConnected()) {
+ return $cached;
+ }
+
+ $stored = $this->configModel->set($uid, $cat, $key, $value);
+
+ $this->db_loaded[$uid][$cat][$key] = $stored;
+
+ return $cached && $stored;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function delete(int $uid, string $cat, string $key)
+ {
+ if (!$uid) {
+ return false;
+ }
+
+ $cacheRemoved = $this->configCache->delete($uid, $cat, $key);
+
+ if (isset($this->db_loaded[$uid][$cat][$key])) {
+ unset($this->db_loaded[$uid][$cat][$key]);
+ }
+
+ if (!$this->configModel->isConnected()) {
+ return $cacheRemoved;
+ }
+
+ $storeRemoved = $this->configModel->delete($uid, $cat, $key);
+
+ return $cacheRemoved || $storeRemoved;
+ }
+}
--- /dev/null
+<?php
+
+namespace Friendica\Core\PConfig;
+
+use Friendica\Core\BasePConfig;
+use Friendica\Model;
+
+/**
+ * This class implements the preload configuration, which will cache
+ * all user config values per call in a cache.
+ *
+ * Minimizes the number of database queries to retrieve configuration values at the cost of memory.
+ */
+class PreloadPConfig extends BasePConfig
+{
+ /** @var array */
+ private $config_loaded;
+
+ /**
+ * @param Cache $configCache The configuration cache
+ * @param Model\Config\PConfig $configModel The configuration model
+ */
+ public function __construct(Cache $configCache, Model\Config\PConfig $configModel)
+ {
+ parent::__construct($configCache, $configModel);
+ $this->config_loaded = [];
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * This loads all config values everytime load is called
+ *
+ */
+ public function load(int $uid, string $cat = 'config')
+ {
+ // Don't load the whole configuration twice or with invalid uid
+ if (!$uid || !empty($this->config_loaded[$uid])) {
+ return;
+ }
+
+ // If not connected, do nothing
+ if (!$this->configModel->isConnected()) {
+ return;
+ }
+
+ $config = $this->configModel->load($uid);
+ $this->config_loaded[$uid] = true;
+
+ // load the whole category out of the DB into the cache
+ $this->configCache->load($uid, $config);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
+ {
+ if (!$uid) {
+ return $default_value;
+ }
+
+ if (empty($this->config_loaded[$uid])) {
+ $this->load($uid);
+ } elseif ($refresh) {
+ if ($this->configModel->isConnected()) {
+ $config = $this->configModel->get($uid, $cat, $key);
+ if (isset($config)) {
+ $this->configCache->set($uid, $cat, $key, $config);
+ }
+ }
+ }
+
+ // use the config cache for return
+ $result = $this->configCache->get($uid, $cat, $key);
+
+ return (isset($result)) ? $result : $default_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function set(int $uid, string $cat, string $key, $value)
+ {
+ if (!$uid) {
+ return false;
+ }
+
+ if (empty($this->config_loaded[$uid])) {
+ $this->load($uid);
+ }
+
+ // set the cache first
+ $cached = $this->configCache->set($uid, $cat, $key, $value);
+
+ // If there is no connected adapter, we're finished
+ if (!$this->configModel->isConnected()) {
+ return $cached;
+ }
+
+ $stored = $this->configModel->set($uid, $cat, $key, $value);
+
+ return $cached && $stored;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function delete(int $uid, string $cat, string $key)
+ {
+ if (!$uid) {
+ return false;
+ }
+
+ if (empty($this->config_loaded[$uid])) {
+ $this->load($uid);
+ }
+
+ $cacheRemoved = $this->configCache->delete($uid, $cat, $key);
+
+ if (!$this->configModel->isConnected()) {
+ return $cacheRemoved;
+ }
+
+ $storeRemoved = $this->configModel->delete($uid, $cat, $key);
+
+ return $cacheRemoved || $storeRemoved;
+ }
+}
}
/**
- * @return Core\Config\IPConfiguration
+ * @return \Friendica\Core\PConfig\IPConfig
*/
public static function pConfig()
{
- return self::$dice->create(Core\Config\IPConfiguration::class);
+ return self::$dice->create(Core\PConfig\IPConfig::class);
}
/**
namespace Friendica\Database;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\System;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\DateTimeFormat;
protected $connected = false;
/**
- * @var ConfigCache
+ * @var Cache
*/
protected $configCache;
/**
protected $in_retrial = false;
private $relation = [];
- public function __construct(ConfigCache $configCache, Profiler $profiler, LoggerInterface $logger, array $server = [])
+ public function __construct(Cache $configCache, Profiler $profiler, LoggerInterface $logger, array $server = [])
{
// We are storing these values for being able to perform a reconnect
$this->configCache = $configCache;
/**
* @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
*
- * @return Cache\ConfigCache
+ * @return Cache
*/
public function createCache(ConfigFileLoader $loader)
{
- $configCache = new Cache\ConfigCache();
+ $configCache = new Cache();
$loader->setupCache($configCache);
return $configCache;
}
/**
- * @param Cache\ConfigCache $configCache The config cache of this adapter
- * @param ConfigModel $configModel The configuration model
+ * @param Cache $configCache The config cache of this adapter
+ * @param ConfigModel $configModel The configuration model
*
* @return Config\IConfig
*/
- public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
+ public function createConfig(Cache $configCache, ConfigModel $configModel)
{
if ($configCache->get('system', 'config_adapter') === 'preload') {
$configuration = new Config\PreloadConfig($configCache, $configModel);
}
/**
- * @param Cache\ConfigCache $configCache The config cache
- * @param Cache\PConfigCache $pConfigCache The personal config cache
- * @param PConfigModel $configModel The configuration model
+ * @param Cache $configCache The config cache
+ * @param \Friendica\Core\PConfig\Cache $pConfigCache The personal config cache
+ * @param PConfigModel $configModel The configuration model
*
- * @return Config\IPConfiguration
+ * @return \Friendica\Core\PConfig\IPConfig
*/
- public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
+ public function createPConfig(Cache $configCache, \Friendica\Core\PConfig\Cache $pConfigCache, PConfigModel $configModel)
{
if ($configCache->get('system', 'config_adapter') === 'preload') {
- $configuration = new Config\PreloadPConfiguration($pConfigCache, $configModel);
+ $configuration = new \Friendica\Core\PConfig\PreloadPConfig($pConfigCache, $configModel);
} else {
- $configuration = new Config\JitPConfiguration($pConfigCache, $configModel);
+ $configuration = new \Friendica\Core\PConfig\JitPConfig($pConfigCache, $configModel);
}
return $configuration;
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
-use Friendica\Core\Config\IPConfiguration;
+use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
private $args;
/** @var App\BaseURL */
private $baseUrl;
- /** @var IPConfiguration */
+ /** @var IPConfig */
private $pConfig;
/** @var LoggerInterface */
private $logger;
public function __construct(Database $dba, L10n $l10n, App\Arguments $args, App\BaseURL $baseUrl,
- IPConfiguration $pConfig, LoggerInterface $logger)
+ IPConfig $pConfig, LoggerInterface $logger)
{
$this->dba = $dba;
$this->l10n = $l10n;
// check legacy basepath settings
$configLoader = new ConfigFileLoader($a->getBasePath());
- $configCache = new Config\Cache\ConfigCache();
+ $configCache = new Config\Cache();
$configLoader->setupCache($configCache);
$confBasepath = $configCache->get('system', 'basepath');
$currBasepath = DI::config()->get('system', 'basepath');
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Network\HTTPException;
/**
* Checks the $_POST settings and updates the config Cache for it
*
- * @param ConfigCache $configCache The current config cache
+ * @param Cache $configCache The current config cache
* @param array $post The $_POST data
* @param string $cat The category of the setting
* @param string $key The key of the setting
* @param null|string $default The default value
*/
- private static function checkSetting(ConfigCache $configCache, array $post, $cat, $key, $default = null)
+ private static function checkSetting(Cache $configCache, array $post, $cat, $key, $default = null)
{
$configCache->set($cat, $key,
Strings::escapeTags(
use Exception;
use Friendica\Core\Addon;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
/**
- * The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see ConfigCache )
+ * The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see Cache )
*
* It is capable of loading the following config files:
* - *.config.php (current)
* First loads the default value for all the configuration keys, then the legacy configuration files, then the
* expected local.config.php
*
- * @param ConfigCache $config The config cache to load to
- * @param bool $raw Setup the raw config format
+ * @param Cache $config The config cache to load to
+ * @param bool $raw Setup the raw config format
*
* @throws Exception
*/
- public function setupCache(ConfigCache $config, $raw = false)
+ public function setupCache(Cache $config, $raw = false)
{
// Load static config files first, the order is important
$config->load($this->loadStaticConfig('defaults'));
/**
* Tries to load the specified core-configuration into the config cache.
*
- * @param ConfigCache $config The Config cache
+ * @param Cache $config The Config cache
*
* @return array The config array (empty if no config found)
*
* @throws Exception if the configuration file isn't readable
*/
- private function loadCoreConfig(ConfigCache $config)
+ private function loadCoreConfig(Cache $config)
{
// try to load legacy ini-files first
foreach ($this->getConfigFiles(true) as $configFile) {
namespace Friendica\Util;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
}
/**
- * @param ConfigCache $configCache The configuration cache
+ * @param Cache $configCache The configuration cache
*/
- public function __construct(ConfigCache $configCache)
+ public function __construct(Cache $configCache)
{
$this->enabled = $configCache->get('system', 'profiler');
$this->rendertime = $configCache->get('rendertime', 'callstack');
$_SERVER
]
],
- Util\BasePath::class => [
+ Util\BasePath::class => [
'constructParams' => [
dirname(__FILE__, 2),
$_SERVER
]
],
- Util\ConfigFileLoader::class => [
+ Util\ConfigFileLoader::class => [
'shared' => true,
'constructParams' => [
[Dice::INSTANCE => '$basepath'],
],
],
- Config\Cache\ConfigCache::class => [
+ Config\Cache::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createCache', [], Dice::CHAIN_CALL],
],
],
- App\Mode::class => [
+ App\Mode::class => [
'call' => [
['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
['determine', [], Dice::CHAIN_CALL],
],
],
- Config\IConfig::class => [
+ Config\IConfig::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createConfig', [], Dice::CHAIN_CALL],
],
],
- Config\IPConfiguration::class => [
+ \Friendica\Core\PConfig\IPConfig::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createPConfig', [], Dice::CHAIN_CALL],
]
],
- Database::class => [
+ Database::class => [
'constructParams' => [
[Dice::INSTANCE => \Psr\Log\NullLogger::class],
$_SERVER,
$this->dice = \Mockery::mock(Dice::class)->makePartial();
$this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php');
- $this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class);
+ $this->configMock = \Mockery::mock(Config\Cache::class);
$this->dice->shouldReceive('create')
- ->with(Config\Cache\ConfigCache::class)
+ ->with(Config\Cache::class)
->andReturn($this->configMock);
$this->mode = \Mockery::mock(App\Mode::class);
$this->dice->shouldReceive('create')
use Friendica\App;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\IMemoryCache;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Lock\ILock;
use Friendica\Database\Database;
$this->assertInstanceOf(ConfigFileLoader::class, $configFileLoader);
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
$this->assertNotEmpty($configCache->getAll());
$this->assertInstanceOf(Profiler::class, $profiler);
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'system' => [
'profiler' => true,
],
use Dice\Dice;
use Friendica\App;
use Friendica\Core\Config\IConfig;
-use Friendica\Core\Config\IPConfiguration;
+use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\Session\ISession;
*/
public function testApiGetUserWithFrioSchema()
{
- $pConfig = $this->dice->create(IPConfiguration::class);
+ $pConfig = $this->dice->create(IPConfig::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
*/
public function testApiGetUserWithCustomFrioSchema()
{
- $pConfig = $this->dice->create(IPConfiguration::class);
+ $pConfig = $this->dice->create(IPConfig::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
$pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
*/
public function testApiGetUserWithEmptyFrioSchema()
{
- $pConfig = $this->dice->create(IPConfiguration::class);
+ $pConfig = $this->dice->create(IPConfig::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
private $databaseMock;
/**
- * @var Config\Cache\ConfigCache|MockInterface
+ * @var \Friendica\Core\Config\Cache|MockInterface
*/
private $configCacheMock;
$this->basePathMock = \Mockery::mock(BasePath::class);
$this->databaseMock = \Mockery::mock(Database::class);
- $this->configCacheMock = \Mockery::mock(Config\Cache\ConfigCache::class);
+ $this->configCacheMock = \Mockery::mock(Config\Cache::class);
}
public function testItEmpty()
use Dice\Dice;
use Friendica\App;
use Friendica\Console\AutomaticInstallation;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Installer;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
private $assertFileDb;
/**
- * @var ConfigCache The configuration cache to check after each test
+ * @var Cache The configuration cache to check after each test
*/
private $configCache;
DI::init($this->dice);
- $this->configCache = new ConfigCache();
+ $this->configCache = new Cache();
$this->configCache->set('system', 'basepath', $this->root->url());
$this->configCache->set('config', 'php_path', trim(shell_exec('which php')));
$this->configCache->set('system', 'theme', 'smarty3');
namespace Friendica\Test\src\Core\Config\Cache;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Test\MockedTest;
use ParagonIE\HiddenString\HiddenString;
];
}
- private function assertConfigValues($data, ConfigCache $configCache)
+ private function assertConfigValues($data, Cache $configCache)
{
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
*/
public function testLoadConfigArray($data)
{
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configCache->load($data);
$this->assertConfigValues($data, $configCache);
]
];
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configCache->load($data);
$configCache->load($override);
*/
public function testLoadConfigArrayWrong()
{
- $configCache = new ConfigCache();
+ $configCache = new Cache();
// empty dataset
$configCache->load([]);
*/
public function testGetAll($data)
{
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configCache->load($data);
$all = $configCache->getAll();
*/
public function testSetGet($data)
{
- $configCache = new ConfigCache();
+ $configCache = new Cache();
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
*/
public function testGetEmpty()
{
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$this->assertNull($configCache->get('something', 'value'));
}
*/
public function testGetCat()
{
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'system' => [
'key1' => 'value1',
'key2' => 'value2',
*/
public function testDelete($data)
{
- $configCache = new ConfigCache($data);
+ $configCache = new Cache($data);
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
*/
public function testKeyDiffWithResult($data)
{
- $configCache = new ConfigCache($data);
+ $configCache = new Cache($data);
$diffConfig = [
'fakeCat' => [
*/
public function testKeyDiffWithoutResult($data)
{
- $configCache = new ConfigCache($data);
+ $configCache = new Cache($data);
$diffConfig = $configCache->getAll();
*/
public function testPasswordHide()
{
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'database' => [
'password' => 'supersecure',
'username' => 'notsecured',
*/
public function testPasswordShow()
{
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'database' => [
'password' => 'supersecure',
'username' => 'notsecured',
*/
public function testEmptyPassword()
{
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'database' => [
'password' => '',
'username' => '',
public function testWrongTypePassword()
{
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'database' => [
'password' => new \stdClass(),
'username' => '',
$this->assertNotEmpty($configCache->get('database', 'password'));
$this->assertEmpty($configCache->get('database', 'username'));
- $configCache = new ConfigCache([
+ $configCache = new Cache([
'database' => [
'password' => 23,
'username' => '',
namespace Friendica\Test\src\Core\Config\Cache;
-use Friendica\Core\Config\Cache\PConfigCache;
+use Friendica\Core\PConfig\Cache;
use Friendica\Test\MockedTest;
class PConfigCacheTest extends MockedTest
];
}
- private function assertConfigValues($data, PConfigCache $configCache, $uid)
+ private function assertConfigValues($data, Cache $configCache, $uid)
{
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
*/
public function testSetGet($data)
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$uid = 345;
foreach ($data as $cat => $values) {
*/
public function testGetCat()
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$uid = 345;
$configCache->load($uid, [
*/
public function testDelete($data)
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$uid = 345;
foreach ($data as $cat => $values) {
*/
public function testKeyDiffWithResult($data)
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$diffConfig = [
'fakeCat' => [
*/
public function testKeyDiffWithoutResult($data)
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$configCache->load(1, $data);
*/
public function testPasswordHide()
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$configCache->load(1, [
'database' => [
*/
public function testPasswordShow()
{
- $configCache = new PConfigCache(false);
+ $configCache = new Cache(false);
$configCache->load(1, [
'database' => [
*/
public function testEmptyPassword()
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$configCache->load(1, [
'database' => [
public function testWrongTypePassword()
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$configCache->load(1, [
'database' => [
$this->assertNotEmpty($configCache->get(1, 'database', 'password'));
$this->assertEmpty($configCache->get(1, 'database', 'username'));
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$configCache->load(1, [
'database' => [
*/
public function testTwoUid()
{
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$configCache->load(1, [
'cat1' => [
// bad UID!
$uid = null;
- $configCache = new PConfigCache();
+ $configCache = new Cache();
$this->assertNull($configCache->get($uid, 'cat1', 'cat2'));
namespace Friendica\Test\src\Core\Config;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Friendica\Model\Config\Config as ConfigModel;
use Friendica\Test\MockedTest;
/** @var ConfigModel|MockInterface */
protected $configModel;
- /** @var ConfigCache */
+ /** @var Cache */
protected $configCache;
/** @var IConfig */
// Create the config model
$this->configModel = Mockery::mock(ConfigModel::class);
- $this->configCache = new ConfigCache();
+ $this->configCache = new Cache();
}
/**
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// assert config is loaded everytime
$this->assertConfig('config', $data['config']);
public function testLoad(array $data, array $possibleCats, array $load)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($load as $loadedCats) {
$this->testedConfig->load($loadedCats);
public function testCacheLoadDouble(array $data1, array $data2, array $expect)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($data1 as $cat => $data) {
$this->testedConfig->load($cat);
$this->configModel->shouldReceive('load')->withAnyArgs()->andReturn([])->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertEmpty($this->testedConfig->getCache()->getAll());
}
->times(3);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertTrue($this->testedConfig->set('test', 'it', $data));
$this->configModel->shouldReceive('set')->with('test', 'it', $data)->andReturn(true)->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertTrue($this->testedConfig->set('test', 'it', $data));
public function testGetWrongWithoutDB()
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
$this->assertNull($this->testedConfig->get('test', 'it'));
$this->configCache->load(['test' => ['it' => 'now']]);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
$this->assertEquals('now', $this->testedConfig->get('test', 'it'));
$this->configCache->load(['test' => ['it' => $data]]);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertEquals($data, $this->testedConfig->get('test', 'it'));
$this->assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// directly set the value to the cache
$this->testedConfig->getCache()->set('test', 'it', 'now');
namespace Friendica\Test\src\Core\Config;
-use Friendica\Core\Config\JitPConfiguration;
+use Friendica\Core\PConfig\JitPConfig;
class JitPConfigurationTest extends PConfigurationTest
{
public function getInstance()
{
- return new JitPConfiguration($this->configCache, $this->configModel);
+ return new JitPConfig($this->configCache, $this->configModel);
}
/**
namespace Friendica\Test\src\Core\Config;
-use Friendica\Core\Config\Cache\PConfigCache;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\PConfig\Cache;
+use Friendica\Core\BasePConfig;
use Friendica\Model\Config\PConfig as PConfigModel;
use Friendica\Test\MockedTest;
use Mockery;
/** @var PConfigModel|MockInterface */
protected $configModel;
- /** @var PConfigCache */
+ /** @var Cache */
protected $configCache;
- /** @var PConfiguration */
+ /** @var BasePConfig */
protected $testedConfig;
/**
// Create the config model
$this->configModel = Mockery::mock(PConfigModel::class);
- $this->configCache = new PConfigCache();
+ $this->configCache = new Cache();
}
/**
- * @return PConfiguration
+ * @return BasePConfig
*/
public abstract function getInstance();
public function testSetUp(int $uid, array $data)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertEmpty($this->testedConfig->getCache()->getAll());
}
public function testLoad(int $uid, array $data, array $possibleCats, array $load)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($load as $loadedCats) {
$this->testedConfig->load($uid, $loadedCats);
public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
foreach ($data1 as $cat => $data) {
$this->testedConfig->load($uid, $cat);
public function testSetGetWithoutDB(int $uid, $data)
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
public function testGetWrongWithoutDB()
{
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
$this->assertNull($this->testedConfig->get(0, 'test', 'it'));
$this->configCache->load($uid, ['test' => ['it' => 'now']]);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// without refresh
$this->assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
$this->configCache->load($uid, ['test' => ['it' => $data]]);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
$this->assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
->once();
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
// directly set the value to the cache
$this->testedConfig->getCache()->set($uid, 'test', 'it', 'now');
$this->configCache->load($data2['uid'], $data2['data']);
$this->testedConfig = $this->getInstance();
- $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache());
+ $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache());
$this->assertConfig($data1['uid'], 'cat1', $data1['data']['cat1']);
$this->assertConfig($data1['uid'], 'cat2', $data1['data']['cat2']);
namespace Friendica\Test\src\Core\Config;
-use Friendica\Core\Config\PreloadPConfiguration;
+use Friendica\Core\PConfig\PreloadPConfig;
class PreloadPConfigurationTest extends PConfigurationTest
{
public function getInstance()
{
- return new PreloadPConfiguration($this->configCache, $this->configModel);
+ return new PreloadPConfig($this->configCache, $this->configModel);
}
/**
namespace Friendica\Core;
use Dice\Dice;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\DI;
use Friendica\Network\CurlResult;
use Friendica\Test\MockedTest;
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
$install = new Installer();
- $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache = \Mockery::mock(Cache::class);
$configCache->shouldReceive('set')->with('config', 'php_path', \Mockery::any())->once();
$configCache->shouldReceive('set')->with('system', 'basepath', '/test/')->once();
namespace Friendica\Test\src\Util\Config;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\ConfigFileLoader;
$this->delConfigFile('local.config.php');
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
->setContent('<?php return true;');
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
}
->setContent(file_get_contents($file));
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
->setContent(file_get_contents($file));
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
->setContent(file_get_contents($file));
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
->setContent(file_get_contents($fileDir . 'B.config.php'));
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
->setContent(file_get_contents($fileDir . 'B.ini.php'));
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
->setContent(file_get_contents($fileDir . 'B.ini.php'));
$configFileLoader = new ConfigFileLoader($this->root->url());
- $configCache = new ConfigCache();
+ $configCache = new Cache();
$configFileLoader->setupCache($configCache);
namespace Friendica\Test\src\Util;
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Friendica\Test\MockedTest;
use Friendica\Util\Profiler;
*/
public function testSetUp()
{
- $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache = \Mockery::mock(Cache::class);
$configCache->shouldReceive('get')
->withAnyArgs()
->andReturn(true)
*/
public function testSaveTimestamp($timestamp, $name, array $functions)
{
- $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache = \Mockery::mock(Cache::class);
$configCache->shouldReceive('get')
->withAnyArgs()
->andReturn(true)
*/
public function testReset($timestamp, $name, array $functions)
{
- $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache = \Mockery::mock(Cache::class);
$configCache->shouldReceive('get')
->withAnyArgs()
->andReturn(true)
->shouldReceive('info')
->once();
- $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache = \Mockery::mock(Cache::class);
$configCache->shouldReceive('get')
->withAnyArgs()
->andReturn(true)
*/
public function testEnableDisable()
{
- $configCache = \Mockery::mock(ConfigCache::class);
+ $configCache = \Mockery::mock(Cache::class);
$configCache->shouldReceive('get')
->with('system', 'profiler')
->andReturn(true)