From 277b692b114782d8d0bc6a4890a2b90fdab9c9e7 Mon Sep 17 00:00:00 2001 From: mohrt Date: Tue, 23 Jul 2002 13:39:59 +0000 Subject: [PATCH] fix error when there are no sections in config file --- Config_File.class.php | 20 +++++++++++++------- NEWS | 2 ++ libs/Config_File.class.php | 20 +++++++++++++------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Config_File.class.php b/Config_File.class.php index 9205e1aa..2212f5d5 100644 --- a/Config_File.class.php +++ b/Config_File.class.php @@ -124,17 +124,23 @@ class Config_File { } if (!empty($var_name)) { - if (empty($section_name)) - { + if (empty($section_name)) { return $this->_config_data[$file_name]["vars"][$var_name]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) + return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; + else + return array(); } - else - return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; } else { - if (empty($section_name)) + if (empty($section_name)) { return (array)$this->_config_data[$file_name]["vars"]; - else - return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) + return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; + else + return array(); + } } } diff --git a/NEWS b/NEWS index eb58a63d..c1371b6e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - fix Config_File class to not error when there are no + sections (Peter Kmet, Monte) - add default modifier logic (Monte) - updated popup_init to be xhtml compliant (Tom Oram, Monte) - fix filename bug with windows (Gary Loescher, Monte) diff --git a/libs/Config_File.class.php b/libs/Config_File.class.php index 9205e1aa..2212f5d5 100644 --- a/libs/Config_File.class.php +++ b/libs/Config_File.class.php @@ -124,17 +124,23 @@ class Config_File { } if (!empty($var_name)) { - if (empty($section_name)) - { + if (empty($section_name)) { return $this->_config_data[$file_name]["vars"][$var_name]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) + return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; + else + return array(); } - else - return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; } else { - if (empty($section_name)) + if (empty($section_name)) { return (array)$this->_config_data[$file_name]["vars"]; - else - return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) + return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; + else + return array(); + } } }