remove basepath and hostname from admin panel and add update path

This commit is contained in:
Philipp Holzer 2019-03-23 15:40:09 +01:00
parent 383a6715c3
commit fa31bb6dde
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
10 changed files with 158 additions and 35 deletions

View file

@ -34,7 +34,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1304); define('DB_UPDATE_VERSION', 1305);
} }
return [ return [

View file

@ -1087,6 +1087,8 @@ function admin_page_site_post(App $a)
update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host); update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host);
// update config // update config
$configCacheSaver = new \Friendica\Util\Config\ConfigCacheSaver($a->getBasePath());
$configCacheSaver->saveToConfigFile('system', 'hostname', parse_url($new_url, PHP_URL_HOST));
Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST)); Config::set('system', 'hostname', parse_url($new_url, PHP_URL_HOST));
Config::set('system', 'url', $new_url); Config::set('system', 'url', $new_url);
$a->setBaseURL($new_url); $a->setBaseURL($new_url);
@ -1105,7 +1107,6 @@ function admin_page_site_post(App $a)
// end relocate // end relocate
$sitename = (!empty($_POST['sitename']) ? Strings::escapeTags(trim($_POST['sitename'])) : ''); $sitename = (!empty($_POST['sitename']) ? Strings::escapeTags(trim($_POST['sitename'])) : '');
$hostname = (!empty($_POST['hostname']) ? Strings::escapeTags(trim($_POST['hostname'])) : '');
$sender_email = (!empty($_POST['sender_email']) ? Strings::escapeTags(trim($_POST['sender_email'])) : ''); $sender_email = (!empty($_POST['sender_email']) ? Strings::escapeTags(trim($_POST['sender_email'])) : '');
$banner = (!empty($_POST['banner']) ? trim($_POST['banner']) : false); $banner = (!empty($_POST['banner']) ? trim($_POST['banner']) : false);
$shortcut_icon = (!empty($_POST['shortcut_icon']) ? Strings::escapeTags(trim($_POST['shortcut_icon'])) : ''); $shortcut_icon = (!empty($_POST['shortcut_icon']) ? Strings::escapeTags(trim($_POST['shortcut_icon'])) : '');
@ -1176,7 +1177,6 @@ function admin_page_site_post(App $a)
$itemcache_duration = (!empty($_POST['itemcache_duration']) ? intval($_POST['itemcache_duration']) : 0); $itemcache_duration = (!empty($_POST['itemcache_duration']) ? intval($_POST['itemcache_duration']) : 0);
$max_comments = (!empty($_POST['max_comments']) ? intval($_POST['max_comments']) : 0); $max_comments = (!empty($_POST['max_comments']) ? intval($_POST['max_comments']) : 0);
$temppath = (!empty($_POST['temppath']) ? Strings::escapeTags(trim($_POST['temppath'])) : ''); $temppath = (!empty($_POST['temppath']) ? Strings::escapeTags(trim($_POST['temppath'])) : '');
$basepath = (!empty($_POST['basepath']) ? Strings::escapeTags(trim($_POST['basepath'])) : '');
$singleuser = (!empty($_POST['singleuser']) ? Strings::escapeTags(trim($_POST['singleuser'])) : ''); $singleuser = (!empty($_POST['singleuser']) ? Strings::escapeTags(trim($_POST['singleuser'])) : '');
$proxy_disabled = !empty($_POST['proxy_disabled']); $proxy_disabled = !empty($_POST['proxy_disabled']);
$only_tag_search = !empty($_POST['only_tag_search']); $only_tag_search = !empty($_POST['only_tag_search']);
@ -1296,7 +1296,6 @@ function admin_page_site_post(App $a)
Config::set('system', 'poco_local_search' , $poco_local_search); Config::set('system', 'poco_local_search' , $poco_local_search);
Config::set('system', 'nodeinfo' , $nodeinfo); Config::set('system', 'nodeinfo' , $nodeinfo);
Config::set('config', 'sitename' , $sitename); Config::set('config', 'sitename' , $sitename);
Config::set('config', 'hostname' , $hostname);
Config::set('config', 'sender_email' , $sender_email); Config::set('config', 'sender_email' , $sender_email);
Config::set('system', 'suppress_tags' , $suppress_tags); Config::set('system', 'suppress_tags' , $suppress_tags);
Config::set('system', 'shortcut_icon' , $shortcut_icon); Config::set('system', 'shortcut_icon' , $shortcut_icon);
@ -1392,10 +1391,6 @@ function admin_page_site_post(App $a)
Config::set('system', 'temppath', $temppath); Config::set('system', 'temppath', $temppath);
if ($basepath != '') {
$basepath = BasePath::getRealPath($basepath);
}
Config::set('system', 'basepath' , $basepath); Config::set('system', 'basepath' , $basepath);
Config::set('system', 'proxy_disabled' , $proxy_disabled); Config::set('system', 'proxy_disabled' , $proxy_disabled);
Config::set('system', 'only_tag_search' , $only_tag_search); Config::set('system', 'only_tag_search' , $only_tag_search);
@ -1536,9 +1531,6 @@ function admin_page_site(App $a)
"develop" => L10n::t("check the development version") "develop" => L10n::t("check the development version")
]; ];
if (empty(Config::get('config', 'hostname'))) {
Config::set('config', 'hostname', $a->getHostName());
}
$diaspora_able = ($a->getURLPath() == ""); $diaspora_able = ($a->getURLPath() == "");
$optimize_max_tablesize = Config::get('system', 'optimize_max_tablesize', -1); $optimize_max_tablesize = Config::get('system', 'optimize_max_tablesize', -1);
@ -1597,7 +1589,6 @@ function admin_page_site(App $a)
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$sitename' => ['sitename', L10n::t("Site name"), Config::get('config', 'sitename'), ''], '$sitename' => ['sitename', L10n::t("Site name"), Config::get('config', 'sitename'), ''],
'$hostname' => ['hostname', L10n::t("Host name"), Config::get('config', 'hostname'), ""],
'$sender_email' => ['sender_email', L10n::t("Sender Email"), Config::get('config', 'sender_email'), L10n::t("The email address your server shall use to send notification emails from."), "", "", "email"], '$sender_email' => ['sender_email', L10n::t("Sender Email"), Config::get('config', 'sender_email'), L10n::t("The email address your server shall use to send notification emails from."), "", "", "email"],
'$banner' => ['banner', L10n::t("Banner/Logo"), $banner, ""], '$banner' => ['banner', L10n::t("Banner/Logo"), $banner, ""],
'$shortcut_icon' => ['shortcut_icon', L10n::t("Shortcut icon"), Config::get('system', 'shortcut_icon'), L10n::t("Link to an icon that will be used for browsers.")], '$shortcut_icon' => ['shortcut_icon', L10n::t("Shortcut icon"), Config::get('system', 'shortcut_icon'), L10n::t("Link to an icon that will be used for browsers.")],
@ -1675,7 +1666,6 @@ function admin_page_site(App $a)
'$itemcache_duration' => ['itemcache_duration', L10n::t("Cache duration in seconds"), Config::get('system', 'itemcache_duration'), L10n::t("How long should the cache files be hold? Default value is 86400 seconds \x28One day\x29. To disable the item cache, set the value to -1.")], '$itemcache_duration' => ['itemcache_duration', L10n::t("Cache duration in seconds"), Config::get('system', 'itemcache_duration'), L10n::t("How long should the cache files be hold? Default value is 86400 seconds \x28One day\x29. To disable the item cache, set the value to -1.")],
'$max_comments' => ['max_comments', L10n::t("Maximum numbers of comments per post"), Config::get('system', 'max_comments'), L10n::t("How much comments should be shown for each post? Default value is 100.")], '$max_comments' => ['max_comments', L10n::t("Maximum numbers of comments per post"), Config::get('system', 'max_comments'), L10n::t("How much comments should be shown for each post? Default value is 100.")],
'$temppath' => ['temppath', L10n::t("Temp path"), Config::get('system', 'temppath'), L10n::t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")], '$temppath' => ['temppath', L10n::t("Temp path"), Config::get('system', 'temppath'), L10n::t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")],
'$basepath' => ['basepath', L10n::t("Base path to installation"), Config::get('system', 'basepath'), L10n::t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")],
'$proxy_disabled' => ['proxy_disabled', L10n::t("Disable picture proxy"), Config::get('system', 'proxy_disabled'), L10n::t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwidth.")], '$proxy_disabled' => ['proxy_disabled', L10n::t("Disable picture proxy"), Config::get('system', 'proxy_disabled'), L10n::t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwidth.")],
'$only_tag_search' => ['only_tag_search', L10n::t("Only search in tags"), Config::get('system', 'only_tag_search'), L10n::t("On large systems the text search can slow down the system extremely.")], '$only_tag_search' => ['only_tag_search', L10n::t("Only search in tags"), Config::get('system', 'only_tag_search'), L10n::t("On large systems the text search can slow down the system extremely.")],

View file

@ -57,13 +57,13 @@ class ConfigCacheLoader extends ConfigCacheManager
/** /**
* Tries to load the specified core-configuration and returns the config array. * Tries to load the specified core-configuration and returns the config array.
* *
* @param string $name The name of the configuration * @param string $name The name of the configuration (default is empty, which means 'local')
* *
* @return array The config array (empty if no config found) * @return array The config array (empty if no config found)
* *
* @throws \Exception if the configuration file isn't readable * @throws \Exception if the configuration file isn't readable
*/ */
public function loadCoreConfig($name) public function loadCoreConfig($name = '')
{ {
if (!empty($this->getConfigFullName($name))) { if (!empty($this->getConfigFullName($name))) {
return $this->loadConfigFile($this->getConfigFullName($name)); return $this->loadConfigFile($this->getConfigFullName($name));
@ -101,13 +101,13 @@ class ConfigCacheLoader extends ConfigCacheManager
/** /**
* Tries to load the legacy config files (.htconfig.php, .htpreconfig.php) and returns the config array. * Tries to load the legacy config files (.htconfig.php, .htpreconfig.php) and returns the config array.
* *
* @param string $name The name of the config file * @param string $name The name of the config file (default is empty, which means .htconfig.php)
* *
* @return array The configuration array (empty if no config found) * @return array The configuration array (empty if no config found)
* *
* @deprecated since version 2018.09 * @deprecated since version 2018.09
*/ */
private function loadLegacyConfig($name) private function loadLegacyConfig($name = '')
{ {
$config = []; $config = [];
if (!empty($this->getHtConfigFullName($name))) { if (!empty($this->getHtConfigFullName($name))) {

View file

@ -10,29 +10,77 @@ abstract class ConfigCacheManager
*/ */
const SUBDIRECTORY = 'config'; const SUBDIRECTORY = 'config';
/**
* The default name of the user defined config file
* @var string
*/
const CONFIG_LOCAL = 'local';
/**
* The default name of the user defined ini file
* @var string
*/
const CONFIG_INI = 'ini';
/**
* The default name of the user defined legacy config file
* @var string
*/
const CONFIG_HTCONFIG = 'htconfig';
protected $baseDir; protected $baseDir;
protected $configDir; protected $configDir;
/**
* @param string $baseDir The base directory of Friendica
*/
public function __construct($baseDir) public function __construct($baseDir)
{ {
$this->baseDir = $baseDir; $this->baseDir = $baseDir;
$this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::SUBDIRECTORY; $this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::SUBDIRECTORY;
} }
protected function getConfigFullName($name) /**
* Gets the full name (including the path) for a *.config.php (default is local.config.php)
*
* @param string $name The config name (default is empty, which means local.config.php)
*
* @return string The full name or empty if not found
*/
protected function getConfigFullName($name = '')
{ {
$name = !empty($name) ? $name : self::CONFIG_LOCAL;
$fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php'; $fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php';
return file_exists($fullName) ? $fullName : ''; return file_exists($fullName) ? $fullName : '';
} }
protected function getIniFullName($name) /**
* Gets the full name (including the path) for a *.ini.php (default is local.ini.php)
*
* @param string $name The config name (default is empty, which means local.ini.php)
*
* @return string The full name or empty if not found
*/
protected function getIniFullName($name = '')
{ {
$name = !empty($name) ? $name : self::CONFIG_INI;
$fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php'; $fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php';
return file_exists($fullName) ? $fullName : ''; return file_exists($fullName) ? $fullName : '';
} }
protected function getHtConfigFullName($name) /**
* Gets the full name (including the path) for a .*.php (default is .htconfig.php)
*
* @param string $name The config name (default is empty, which means .htconfig.php)
*
* @return string The full name or empty if not found
*/
protected function getHtConfigFullName($name = '')
{ {
$name = !empty($name) ? $name : self::CONFIG_HTCONFIG;
$fullName = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php'; $fullName = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
return file_exists($fullName) ? $fullName : ''; return file_exists($fullName) ? $fullName : '';
} }

View file

@ -20,18 +20,49 @@ class ConfigCacheSaver extends ConfigCacheManager
const INDENT = "\t"; const INDENT = "\t";
/** /**
* Saves a given value to the config file * The settings array to save to
* @var array
*/
private $settings = [];
/**
* Adds a given value to the config file
* Either it replaces the current value or it will get added * Either it replaces the current value or it will get added
* *
* @param string $cat The configuration category * @param string $cat The configuration category
* @param string $key The configuration key * @param string $key The configuration key
* @param string $value The new value * @param string $value The new value
*/ */
public function saveToConfigFile($cat, $key, $value) public function addConfigValue($cat, $key, $value)
{ {
$this->saveToLegacyConfig('htpreconfig', $cat, $key, $value); $this->settings[$cat][$key] = $value;
$this->saveToLegacyConfig('htconfig', $cat, $key, $value); }
$this->saveToCoreConfig('local', $cat, $key, $value);
public function reset()
{
$this->settings = [];
}
public function saveToConfigFile($name = '')
{
$saved = false;
if (!empty($this->getConfigFullName($name))) {
$this->saveConfigFile($this->getConfigFullName($name));
$saved = true;
}
if (!empty($this->getIniFullName($name))) {
$this->saveINIConfigFile($this->getIniFullName($name));
$saved = true;
}
if (!empty($this->getHtConfigFullName($name))) {
$this->saveToLegacyConfig($this->getHtConfigFullName($name));
$saved = true;
}
return $saved;
} }
/** /**

View file

@ -68,7 +68,12 @@ class ConfigCacheLoaderTest extends MockedTest
{ {
$this->delConfigFile('local.config.php'); $this->delConfigFile('local.config.php');
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR; $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR .
'local.config.php';
vfsStream::newFile('local.config.php') vfsStream::newFile('local.config.php')
->at($this->root->getChild('config')) ->at($this->root->getChild('config'))
@ -95,7 +100,12 @@ class ConfigCacheLoaderTest extends MockedTest
{ {
$this->delConfigFile('local.config.php'); $this->delConfigFile('local.config.php');
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR; $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR .
'local.ini.php';
vfsStream::newFile('local.ini.php') vfsStream::newFile('local.ini.php')
->at($this->root->getChild('config')) ->at($this->root->getChild('config'))
@ -121,7 +131,12 @@ class ConfigCacheLoaderTest extends MockedTest
{ {
$this->delConfigFile('local.config.php'); $this->delConfigFile('local.config.php');
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR; $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR .
'.htconfig.test.php';
vfsStream::newFile('.htconfig.php') vfsStream::newFile('.htconfig.php')
->at($this->root) ->at($this->root)
@ -165,7 +180,12 @@ class ConfigCacheLoaderTest extends MockedTest
vfsStream::create($structure, $this->root); vfsStream::create($structure, $this->root);
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR; $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR .
'local.config.php';
vfsStream::newFile('test.config.php') vfsStream::newFile('test.config.php')
->at($this->root->getChild('addon')->getChild('test')->getChild('config')) ->at($this->root->getChild('addon')->getChild('test')->getChild('config'))

View file

@ -32,30 +32,36 @@ class ConfigCacheSaverTest extends MockedTest
{ {
$this->delConfigFile('local.config.php'); $this->delConfigFile('local.config.php');
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR . $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR . 'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR .
'local.config.php'; 'local.config.php';
vfsStream::newFile('local.config.php') vfsStream::newFile('local.config.php')
->at($this->root->getChild('config')) ->at($this->root->getChild('config'))
->setContent(file_get_contents($file)); ->setContent(file_get_contents($file));
$configCacheSaver = new ConfigCacheSaver($this->root->url()); $configCacheSaver = new ConfigCacheSaver($this->root->url());
$configCacheLoader = new ConfigCacheLoader($this->root->url(), $this->mode); $configCacheLoader = new ConfigCacheLoader($this->root->url(), $this->mode);
$configCache = new ConfigCache(); $configCache = new ConfigCache();
$configCacheLoader->loadConfigFiles($configCache); $configCacheLoader->loadConfigFiles($configCache);
$this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email')); $this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
$this->assertEquals('!<unset>!', $configCache->get('config', 'test_val')); $this->assertNull($configCache->get('config', 'test_val'));
$configCacheSaver->saveToConfigFile('config', 'admin_email', 'new@mail.it'); $configCacheSaver->saveToConfigFile('config', 'admin_email', 'new@mail.it');
$configCacheSaver->saveToConfigFile('config', 'test_val', 'Testing$!"$with@all.we can!'); $configCacheSaver->saveToConfigFile('config', 'test_val', 'Testing$!"$with@all.we can!');
$newConfigCache = new ConfigCache(); $newConfigCache = new ConfigCache();
$configCacheLoader->loadConfigFiles($newConfigCache); $configCacheLoader->loadConfigFiles($newConfigCache);
$this->assertEquals('new@mail.it', $newConfigCache->get('config', 'admin_email')); $this->assertEquals('new@mail.it', $newConfigCache->get('config', 'admin_email'));
$this->assertEquals('Testing$!"$with@all.we can!', $newConfigCache->get('config', 'test_val')); $this->assertEquals('Testing$!"$with@all.we can!', $newConfigCache->get('config', 'test_val'));
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')); $this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php.old')); $this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php.old'));
$this->assertFalse($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php.tmp')); $this->assertFalse($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php.tmp'));
$this->assertEquals(file_get_contents($file), file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php.old')->url())); $this->assertEquals(file_get_contents($file), file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php.old')->url()));
} }
/** /**
@ -65,7 +71,6 @@ class ConfigCacheSaverTest extends MockedTest
{ {
$this->delConfigFile('local.config.php'); $this->delConfigFile('local.config.php');
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR . $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR . 'datasets' . DIRECTORY_SEPARATOR .
@ -79,7 +84,7 @@ class ConfigCacheSaverTest extends MockedTest
$configCache = new ConfigCache(); $configCache = new ConfigCache();
$configCacheLoader->loadConfigFiles($configCache); $configCacheLoader->loadConfigFiles($configCache);
$this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email')); $this->assertEquals('admin@test.it', $configCache->get('config', 'admin_email'));
$this->assertEquals('!<unset>!', $configCache->get('config', 'test_val')); $this->assertNull($configCache->get('config', 'test_val'));
$configCacheSaver->saveToConfigFile('config', 'admin_email', 'new@mail.it'); $configCacheSaver->saveToConfigFile('config', 'admin_email', 'new@mail.it');
$configCacheSaver->saveToConfigFile('config', 'test_val', "Testing@with.all we can"); $configCacheSaver->saveToConfigFile('config', 'test_val', "Testing@with.all we can");
$newConfigCache = new ConfigCache(); $newConfigCache = new ConfigCache();

View file

@ -12,6 +12,7 @@ use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\Config\ConfigCacheSaver;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
/** /**
@ -346,3 +347,32 @@ function update_1298()
} }
return Update::SUCCESS; return Update::SUCCESS;
} }
/**
* @see https://github.com/friendica/friendica/pull/6815
*
* @return int Success
*/
function update_1303()
{
$app = \Friendica\BaseObject::getApp();
$configCache = $app->getConfigCache();
$configCacheSaver = new ConfigCacheSaver($app->getBasePath());
$updateConfigEntry = function($cat, $key) use ($configCache, $configCacheSaver) {
// check if the config file differs from the whole configuration (= The db contains other values)
$fileConfig = $configCache->get($cat, $key);
if ($fileConfig === '!<unset>!') {
$fileConfig = null;
}
$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);
} else {
Logger::info('No Difference in config found', ['cat' => $cat, 'key' => $key, 'value' => $fileConfig, 'saved' => $savedConfig]);
}
};
$updateConfigEntry('config', 'hostname');
$updateConfigEntry('system', 'basepath');
return Update::SUCCESS;
}

View file

@ -46,7 +46,6 @@
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'> <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
{{include file="field_input.tpl" field=$sitename}} {{include file="field_input.tpl" field=$sitename}}
{{include file="field_input.tpl" field=$hostname}}
{{include file="field_input.tpl" field=$sender_email}} {{include file="field_input.tpl" field=$sender_email}}
{{include file="field_textarea.tpl" field=$banner}} {{include file="field_textarea.tpl" field=$banner}}
{{include file="field_input.tpl" field=$shortcut_icon}} {{include file="field_input.tpl" field=$shortcut_icon}}
@ -125,7 +124,6 @@
{{include file="field_input.tpl" field=$optimize_fragmentation}} {{include file="field_input.tpl" field=$optimize_fragmentation}}
{{include file="field_input.tpl" field=$abandon_days}} {{include file="field_input.tpl" field=$abandon_days}}
{{include file="field_input.tpl" field=$temppath}} {{include file="field_input.tpl" field=$temppath}}
{{include file="field_input.tpl" field=$basepath}}
{{include file="field_checkbox.tpl" field=$suppress_tags}} {{include file="field_checkbox.tpl" field=$suppress_tags}}
{{include file="field_checkbox.tpl" field=$nodeinfo}} {{include file="field_checkbox.tpl" field=$nodeinfo}}
{{include file="field_select.tpl" field=$check_new_version_url}} {{include file="field_select.tpl" field=$check_new_version_url}}

View file

@ -29,6 +29,7 @@ return [
], ],
'system' => [ 'system' => [
'urlpath' => '{{$urlpath}}', 'urlpath' => '{{$urlpath}}',
'basepath' => '{{$basepath}}',
'default_timezone' => '{{$timezone}}', 'default_timezone' => '{{$timezone}}',
'language' => '{{$language}}', 'language' => '{{$language}}',
], ],