X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FApp.php;h=7622a1a0ce3aacb5e2795fbdd6b9c1e7b572e78e;hb=78a7e130ae7f5e5bca1fa51a49000ae3ef7a16f5;hp=3761004575a8157c38b107a556204f30b5140afb;hpb=adbc1d3224e8a6875b228e9b506885f10aa74252;p=friendica.git diff --git a/src/App.php b/src/App.php index 3761004575..7622a1a0ce 100644 --- a/src/App.php +++ b/src/App.php @@ -406,13 +406,13 @@ class App } if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php')) { - $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php'); + $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.ini.php', true); } } /** * Tries to load the specified configuration file into the App->config array. - * Overwrites previously set values. + * Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config. * * The config format is INI and the template for configuration files is the following: * @@ -425,9 +425,10 @@ class App * // Keep this line * * @param type $filepath + * @param bool $overwrite Force value overwrite if the config key already exists * @throws Exception */ - public function loadConfigFile($filepath) + public function loadConfigFile($filepath, $overwrite = false) { if (!file_exists($filepath)) { throw new Exception('Error parsing non-existent config file ' . $filepath); @@ -443,7 +444,11 @@ class App foreach ($config as $category => $values) { foreach ($values as $key => $value) { - $this->setConfigValue($category, $key, $value); + if ($overwrite) { + $this->setConfigValue($category, $key, $value); + } else { + $this->setDefaultConfigValue($category, $key, $value); + } } } } @@ -461,7 +466,7 @@ class App // Load the local addon config file to overwritten default addon config values if (file_exists($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php')) { - $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php'); + $this->loadConfigFile($this->basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'addon.ini.php', true); } } @@ -1149,7 +1154,11 @@ class App $meminfo = []; foreach ($memdata as $line) { - list($key, $val) = explode(':', $line); + $data = explode(':', $line); + if (count($data) != 2) { + continue; + } + list($key, $val) = $data; $meminfo[$key] = (int) trim(str_replace('kB', '', $val)); $meminfo[$key] = (int) ($meminfo[$key] / 1024); } @@ -1315,6 +1324,20 @@ class App return $return; } + /** + * Sets a default value in the config cache. Ignores already existing keys. + * + * @param string $cat Config category + * @param string $k Config key + * @param mixed $v Default value to set + */ + private function setDefaultConfigValue($cat, $k, $v) + { + if (!isset($this->config[$cat][$k])) { + $this->setConfigValue($cat, $k, $v); + } + } + /** * Sets a value in the config cache. Accepts raw output from the config table *