mirror of
https://github.com/friendica/friendica
synced 2025-04-26 18:30:11 +00:00
Adding ConfigFileSaver and tests
This commit is contained in:
parent
fa31bb6dde
commit
49def0dc27
21 changed files with 493 additions and 473 deletions
12
update.php
12
update.php
|
@ -12,7 +12,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Util\Config\ConfigCacheSaver;
|
||||
use Friendica\Util\Config\ConfigFileSaver;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
/**
|
||||
|
@ -357,8 +357,9 @@ function update_1303()
|
|||
{
|
||||
$app = \Friendica\BaseObject::getApp();
|
||||
$configCache = $app->getConfigCache();
|
||||
$configCacheSaver = new ConfigCacheSaver($app->getBasePath());
|
||||
$updateConfigEntry = function($cat, $key) use ($configCache, $configCacheSaver) {
|
||||
$configFileSaver = new ConfigFileSaver($app->getBasePath());
|
||||
|
||||
$updateConfigEntry = function($cat, $key) use ($configCache, $configFileSaver) {
|
||||
// check if the config file differs from the whole configuration (= The db contains other values)
|
||||
$fileConfig = $configCache->get($cat, $key);
|
||||
if ($fileConfig === '!<unset>!') {
|
||||
|
@ -367,11 +368,14 @@ function update_1303()
|
|||
$savedConfig = Config::get($cat, $key, null, true);
|
||||
if ($fileConfig !== $savedConfig) {
|
||||
Logger::info('Difference in config found', ['cat' => $cat, 'key' => $key, 'file' => $fileConfig, 'saved' => $savedConfig]);
|
||||
$configCacheSaver->saveToConfigFile($cat, $key, $savedConfig);
|
||||
$configFileSaver->addConfigValue($cat, $key, $savedConfig);
|
||||
} else {
|
||||
Logger::info('No Difference in config found', ['cat' => $cat, 'key' => $key, 'value' => $fileConfig, 'saved' => $savedConfig]);
|
||||
}
|
||||
};
|
||||
|
||||
$configFileSaver->saveToConfigFile();
|
||||
|
||||
$updateConfigEntry('config', 'hostname');
|
||||
$updateConfigEntry('system', 'basepath');
|
||||
return Update::SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue