fillConfigVoids to set default value of empty config options

This commit is contained in:
Mikael Nordfeldth 2016-03-07 22:55:52 +01:00
parent 265fa12917
commit 4e5c0e70a6
2 changed files with 11 additions and 1 deletions

View File

@ -134,7 +134,8 @@ class File_thumbnail extends Managed_DataObject
throw new ClientException(_('Invalid filename.'));
}
$dir = common_config('thumbnail', 'dir') ?: File::path('thumb');
// NOTE: If this is empty, it will be set to File::path('thumb')
$dir = common_config('thumbnail', 'dir');
if (!in_array($dir[mb_strlen($dir)-1], ['/', '\\'])) {
$dir .= DIRECTORY_SEPARATOR;

View File

@ -141,6 +141,7 @@ class GNUsocial
// Load settings from database; note we need autoload for this
Config::loadSettings();
self::fillConfigVoids();
self::verifyLoadedConfig();
self::initPlugins();
@ -420,6 +421,14 @@ class GNUsocial
}
}
static function fillConfigVoids()
{
// special cases on empty configuration options
if (!common_config('thumbnail', 'dir')) {
common_config_set('thumbnail', 'dir', File::path('thumb'));
}
}
/**
* Verify that the loaded config is good. Not complete, but will
* throw exceptions on common configuration problems I hope.