From 5363698020ab5774b4b13c148ee7fa30af1eee4d Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 8 Jun 2015 14:20:21 +0000 Subject: [PATCH] Make sure appropriate defaults for omitted configs are used --- src/mibew/libs/common/configurations.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/mibew/libs/common/configurations.php b/src/mibew/libs/common/configurations.php index 94b50a71..9b705bb6 100644 --- a/src/mibew/libs/common/configurations.php +++ b/src/mibew/libs/common/configurations.php @@ -33,13 +33,19 @@ function load_system_configs() if (is_null($configs)) { $parser = new YamlParser(); $configs = $parser->parse(file_get_contents(MIBEW_FS_ROOT . '/configs/config.yml')); - $configs += array( - // Mailer configs are not necessary and can be omited but the - // section must exist anyway. - 'mailer' => array(), - // Cache section must extst too. - 'cache' => array(), - ); + + // Mailer configs are not necessary and can be omited but the section + // must exist anyway. Empty statement is used to make sure null, false + // and "" will be converted to an empty array. + if (empty($configs['mailer'])) { + $configs['mailer'] = array(); + } + + // Cache section must extst too. The logic behind "empty" statement is + // the same as above. + if (empty($configs['cache'])) { + $configs['cache'] = array(); + } } return $configs;