Config fixings

- Delete now really overwrites static default/setting.config.php keys
- Delete now really overwrites static default/setting.config.php categories
- The Update::check() routine is added to different places
- Merge the given config file with the new config before writing
- Remove ConfigTransaction::get() because it's no more reliable
This commit is contained in:
Philipp 2023-01-06 01:02:47 +01:00
parent cdd57275eb
commit 5aa8e8adf1
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
13 changed files with 221 additions and 181 deletions

View file

@ -441,4 +441,74 @@ class ConfigFileManagerTest extends MockedTest
'special' => $specialChars,
]], $configCache2->getDataBySource(Cache::SOURCE_DATA));
}
/**
* If we delete something with the Cache::delete() functionality, be sure to override the underlying source as well
*/
public function testDeleteKeyOverwrite()
{
$this->delConfigFile('node.config.php');
$fileDir = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR;
vfsStream::newFile('B.config.php')
->at($this->root->getChild('config'))
->setContent(file_get_contents($fileDir . 'B.config.php'));
$configFileManager = (new Config())->createConfigFileManager($this->root->url());
$configCache = new Cache();
$configFileManager->setupCache($configCache);
$configCache->delete('system', 'default_timezone', Cache::SOURCE_DATA);
$configFileManager->saveData($configCache);
// assert that system.default_timezone is now null, even it's set with settings.conf.php
$configCache = new Cache();
$configFileManager->setupCache($configCache);
self::assertNull($configCache->get('system', 'default_timezone'));
}
/**
* If we delete something with the Cache::delete() functionality, be sure to override the underlying source as well
*/
public function testDeleteCategoryOverwrite()
{
$this->delConfigFile('node.config.php');
$fileDir = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR;
vfsStream::newFile('B.config.php')
->at($this->root->getChild('config'))
->setContent(file_get_contents($fileDir . 'B.config.php'));
$configFileManager = (new Config())->createConfigFileManager($this->root->url());
$configCache = new Cache();
$configFileManager->setupCache($configCache);
$configCache->delete('system');
$configFileManager->saveData($configCache);
// assert that system.default_timezone is now null, even it's set with settings.conf.php
$configCache = new Cache();
$configFileManager->setupCache($configCache);
self::assertNull($configCache->get('system', 'default_timezone'));
}
}