]> git.mxchange.org Git - friendica.git/commitdiff
bugfix: add lost changes due merge
authorPhilipp Holzer <admin+github@philipp.info>
Fri, 12 Jul 2019 21:01:01 +0000 (23:01 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Sun, 14 Jul 2019 20:12:45 +0000 (22:12 +0200)
src/Core/Config/PConfiguration.php
src/Database/Database.php
src/Factory/ConfigFactory.php
src/Factory/DependencyFactory.php
tests/Util/AppMockTrait.php

index 79ed1a61e6d0fe6eaeb429b3ed08e42939d02bb0..e69981c08c182543079b96d93de0b30cc2a84dd5 100644 (file)
@@ -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
index 14381ae922d791d8a1079a42cfde9cfa9317575a..0d1540f7cd94fca392d76c194e65ead662c84723 100644 (file)
@@ -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;
index 7764d89900417c3d2499b3d171b15222b30197ac..79448b8b8334a043a6836d76717411bdd4a9799a 100644 (file)
@@ -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);
index 656a255b2ba2e4b782fb32b87cf79938cbfc4f53..0ac56f6c5ec6cf477bae0c582123e471a2b4d6fd 100644 (file)
@@ -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);
index 0ca625ee0e5b8ee98ab5737491e478c0dc666064..52941d0d513474a699c8dd0cbce49ab9cbb6dd8c 100644 (file)
@@ -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);