From 4913502922391d6c6852ed1d0325461dc500da21 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Fri, 12 Jul 2019 23:01:01 +0200 Subject: [PATCH] bugfix: add lost changes due merge --- src/Core/Config/PConfiguration.php | 6 +++--- src/Database/Database.php | 14 ++++++++++++++ src/Factory/ConfigFactory.php | 10 ++++++---- src/Factory/DependencyFactory.php | 4 +++- tests/Util/AppMockTrait.php | 7 ++++--- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Core/Config/PConfiguration.php b/src/Core/Config/PConfiguration.php index 79ed1a61e6..e69981c08c 100644 --- a/src/Core/Config/PConfiguration.php +++ b/src/Core/Config/PConfiguration.php @@ -6,7 +6,7 @@ namespace Friendica\Core\Config; * This class is responsible for the user-specific configuration values in Friendica * The values are set through the Config-DB-Table (per Config-DB-adapter @see Adapter\IPConfigAdapter ) * - * The configuration cache (@see Cache\IPConfigCache ) is used for temporary caching of database calls. This will + * The configuration cache (@see Cache\PConfigCache ) is used for temporary caching of database calls. This will * increase the performance. */ class PConfiguration @@ -35,7 +35,7 @@ class PConfiguration * @brief 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 ( @see IPConfigCache ) + * the cache ( @see PConfigCache ) * * @param string $uid The user_id * @param string $cat The category of the configuration value @@ -59,7 +59,7 @@ class PConfiguration * * 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 IConfigCache ). + * (@see IConfigAdapter ) or from the $this->configCache (@see PConfigCache ). * * @param string $uid The user_id * @param string $cat The category of the configuration value diff --git a/src/Database/Database.php b/src/Database/Database.php index 14381ae922..0d1540f7cd 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -161,6 +161,15 @@ class Database $this->logger = $logger; } + /** + * Sets the profiler for DBA + * + * @param Profiler $profiler + */ + public function setProfiler(Profiler $profiler) + { + $this->profiler = $profiler; + } /** * Disconnects the current database connection */ @@ -323,6 +332,11 @@ class Database } } + public function isConnected() + { + return $this->connected; + } + public function connected() { $connected = false; diff --git a/src/Factory/ConfigFactory.php b/src/Factory/ConfigFactory.php index 7764d89900..79448b8b83 100644 --- a/src/Factory/ConfigFactory.php +++ b/src/Factory/ConfigFactory.php @@ -6,6 +6,7 @@ use Friendica\Core; use Friendica\Core\Config; use Friendica\Core\Config\Adapter; use Friendica\Core\Config\Cache; +use Friendica\Model\Config\Config as ConfigModel; use Friendica\Util\Config\ConfigFileLoader; class ConfigFactory @@ -24,19 +25,20 @@ class ConfigFactory } /** + * @param Cache\ConfigCache $configCache The config cache of this adapter + * @param ConfigModel $configModel The configuration model * @param Cache\ConfigCache $configCache The config cache * * @return Config\Configuration */ - public static function createConfig(Cache\ConfigCache $configCache) + public static function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel) { if ($configCache->get('system', 'config_adapter') === 'preload') { - $configAdapter = new Adapter\PreloadConfigAdapter(); + $configuration = new Config\PreloadConfiguration($configCache, $configModel); } else { - $configAdapter = new Adapter\JITConfigAdapter(); + $configuration = new Config\JitConfiguration($configCache, $configModel); } - $configuration = new Config\Configuration($configCache, $configAdapter); // Set the config in the static container for legacy usage Core\Config::init($configuration); diff --git a/src/Factory/DependencyFactory.php b/src/Factory/DependencyFactory.php index 656a255b2b..0ac56f6c5e 100644 --- a/src/Factory/DependencyFactory.php +++ b/src/Factory/DependencyFactory.php @@ -8,6 +8,7 @@ use Friendica\Factory; use Friendica\Util\BasePath; use Friendica\Util\BaseURL; use Friendica\Util\Config; +use Psr\Log\NullLogger; class DependencyFactory { @@ -31,7 +32,8 @@ class DependencyFactory $configCache = Factory\ConfigFactory::createCache($configLoader); $profiler = Factory\ProfilerFactory::create($configCache); $database = Factory\DBFactory::init($configCache, $profiler, $_SERVER); - $config = Factory\ConfigFactory::createConfig($configCache); + $configModel = new \Friendica\Model\Config\Config($database); + $config = Factory\ConfigFactory::createConfig($configCache, $configModel); // needed to call PConfig::init() Factory\ConfigFactory::createPConfig($configCache, new PConfigCache()); $logger = Factory\LoggerFactory::create($channel, $database, $config, $profiler); diff --git a/tests/Util/AppMockTrait.php b/tests/Util/AppMockTrait.php index 0ca625ee0e..52941d0d51 100644 --- a/tests/Util/AppMockTrait.php +++ b/tests/Util/AppMockTrait.php @@ -44,12 +44,13 @@ trait AppMockTrait public function mockApp(vfsStreamDirectory $root, $raw = false) { $this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class); + $this->configMock->shouldReceive('getAll')->andReturn([])->once(); $this->mode = \Mockery::mock(App\Mode::class); - $configAdapterMock = \Mockery::mock(Config\Adapter\IConfigAdapter::class); + $configModel= \Mockery::mock(\Friendica\Model\Config\Config::class); // Disable the adapter - $configAdapterMock->shouldReceive('isConnected')->andReturn(false); + $configModel->shouldReceive('isConnected')->andReturn(false); - $config = new Config\Configuration($this->configMock, $configAdapterMock); + $config = new Config\JitConfiguration($this->configMock, $configModel); // Initialize empty Config Config::init($config); -- 2.39.5