]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
fillConfigVoids to set default value of empty config options
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 7 Mar 2016 21:55:52 +0000 (22:55 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 7 Mar 2016 21:55:52 +0000 (22:55 +0100)
classes/File_thumbnail.php
lib/gnusocial.php

index 925a3b24295ab057ca30db27e0d1a234ac385de5..3f36e26563724dd54e488d5cf35d57f9d46bce3f 100644 (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;
index f07d2c24468e46d34fa1e67ac695b4f04fb851c8..3450b048883918e675238e31c3e55e9a02ef4ed5 100644 (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.