From 6c43e9c2e0934a9da2cb7947024ca7e3702c3f91 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 28 Feb 2016 13:31:21 +0100 Subject: [PATCH] Verify loaded config function, must be completed further. --- lib/gnusocial.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/gnusocial.php b/lib/gnusocial.php index 277c41e7c8..2ad688a790 100644 --- a/lib/gnusocial.php +++ b/lib/gnusocial.php @@ -141,6 +141,8 @@ class GNUsocial // Load settings from database; note we need autoload for this Config::loadSettings(); + self::verifyLoadedConfig(); + self::initPlugins(); } @@ -418,6 +420,23 @@ class GNUsocial } } + /** + * Verify that the loaded config is good. Not complete, but will + * throw exceptions on common configuration problems I hope. + * + * Might make changes to the filesystem, to created dirs, but will + * not make database changes. + */ + static function verifyLoadedConfig() + { + if (common_config('htmlpurifier', 'Cache.DefinitionImpl') === 'Serializer' + && !is_dir(common_config('htmlpurifier', 'Cache.SerializerPath'))) { + if (!mkdir(common_config('htmlpurifier', 'Cache.SerializerPath'))) { + throw new ServerException('Could not create HTMLPurifier cache dir: '._ve(common_config('htmlpurifier', 'Cache.SerializerPath'))); + } + } + } + /** * Are we running from the web with HTTPS? *