bugfix: add lost changes due merge

This commit is contained in:
Philipp Holzer 2019-07-12 23:01:01 +02:00
parent 8f0aa0ca5a
commit 4913502922
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
5 changed files with 30 additions and 11 deletions

View 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

View 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;

View 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);

View 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);

View 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);