]> git.mxchange.org Git - friendica.git/commitdiff
- Adding additional legacy .htconfig information
authorPhilipp Holzer <admin@philipp.info>
Sat, 16 Mar 2019 19:04:11 +0000 (20:04 +0100)
committerPhilipp Holzer <admin@philipp.info>
Sat, 16 Mar 2019 19:06:53 +0000 (20:06 +0100)
src/Core/Config/Cache/ConfigCacheLoader.php
tests/datasets/config/.htconfig.test.php
tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php

index b043bf27cbc21b0e19d0d5ab194261ec90d1e332..95d6041d46d95e8d92b991420f21ec333428ecca 100644 (file)
@@ -103,47 +103,61 @@ class ConfigCacheLoader
        {
                $filePath = $this->baseDir  . DIRECTORY_SEPARATOR . '.' . $name . '.php';
 
+               $config = [];
+
                if (file_exists($filePath)) {
-                       $a = new \stdClass();
-                       $a->config = [];
                        include $filePath;
 
                        if (isset($db_host)) {
-                               $a->config['database']['hostname'] = $db_host;
+                               $config['database']['hostname'] = $db_host;
                                unset($db_host);
                        }
                        if (isset($db_user)) {
-                               $a->config['database']['username'] = $db_user;
+                               $config['database']['username'] = $db_user;
                                unset($db_user);
                        }
                        if (isset($db_pass)) {
-                               $a->config['database']['password'] = $db_pass;
+                               $config['database']['password'] = $db_pass;
                                unset($db_pass);
                        }
                        if (isset($db_data)) {
-                               $a->config['database']['database'] = $db_data;
+                               $config['database']['database'] = $db_data;
                                unset($db_data);
                        }
                        if (isset($a->config['system']['db_charset'])) {
-                               $a->config['database']['charset'] = $a->config['system']['charset'];
+                               $a->config['database']['charset'] = $config['system']['charset'];
                        }
                        if (isset($pidfile)) {
-                               $a->config['system']['pidfile'] = $pidfile;
+                               $config['system']['pidfile'] = $pidfile;
                                unset($pidfile);
                        }
                        if (isset($default_timezone)) {
-                               $a->config['system']['default_timezone'] = $default_timezone;
+                               $config['system']['default_timezone'] = $default_timezone;
                                unset($default_timezone);
                        }
                        if (isset($lang)) {
-                               $a->config['system']['language'] = $lang;
+                               $config['system']['language'] = $lang;
                                unset($lang);
                        }
-
-                       return $a->config;
-               } else {
-                       return [];
+                       if (isset($admin_email)) {
+                               $config['config']['admin_email'] = $admin_email;
+                               unset($admin_email);
+                       }
+                       if (isset($admin_nickname)) {
+                               $config['config']['admin_nickname'] = $admin_nickname;
+                               unset($admin_nickname);
+                       }
+                       if (isset($php_path)) {
+                               $config['config']['php_path'] = $php_path;
+                               unset($php_path);
+                       }
+                       if (isset($max_import_size)) {
+                               $config['config']['max_import_size'] = $max_import_size;
+                               unset($max_import_size);
+                       }
                }
+
+               return $config;
        }
 
        /**
index 88ba4e3ef38b9f9f21a956c15106ae555026e2ce..78bb6bcdae423e512cc6108581b517fa23752d52 100644 (file)
@@ -8,6 +8,12 @@ $db_user = 'testuser';
 $db_pass = 'testpw';
 $db_data = 'testdb';
 
+$admin_email = 'admin@friendica.local';
+$admin_nickname = 'Friendly admin';
+
 $pidfile = '/var/run/friendica.pid';
 $default_timezone = 'Europe/Berlin';
 $lang = 'fr';
+
+$php_path = '/another/php';
+$max_import_size = 999;
\ No newline at end of file
index d473aec00c14e00f1640b7c684d0dca78e5ba6cf..4fd0b46509c4c3e635b32f829a6302a22bd61790 100644 (file)
@@ -135,6 +135,12 @@ class ConfigCacheLoaderTest extends MockedTest
                $this->assertEquals('/var/run/friendica.pid', $configCache->get('system', 'pidfile'));
                $this->assertEquals('Europe/Berlin', $configCache->get('system', 'default_timezone'));
                $this->assertEquals('fr', $configCache->get('system', 'language'));
+
+               $this->assertEquals('admin@friendica.local', $configCache->get('config', 'admin_email'));
+               $this->assertEquals('Friendly admin', $configCache->get('config', 'admin_nickname'));
+
+               $this->assertEquals('/another/php', $configCache->get('config', 'php_path'));
+               $this->assertEquals('999', $configCache->get('config', 'max_import_size'));
        }
 
        public function testLoadAddonConfig()