diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index 915bf9498e0..e20f8dcfb56 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -77,7 +77,12 @@ public function read($file) { } else { $values = array(); foreach ($contents as $section => $attribs) { - $values[$section] = $this->_parseNestedValues($attribs); + if (is_array($attribs)) { + $values[$section] = $this->_parseNestedValues($attribs); + } else { + $parse = $this->_parseNestedValues(array($attribs)); + $values[$section] = array_shift($parse); + } } } return $values; diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index 2fb8eb2dd00..3db8bb94232 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -64,6 +64,22 @@ function testReadingOnlyOneSection() { $this->assertEquals('administrators', $config['groups']); } +/** + * test without section + * + * @return void + */ + public function testReadingWithoutSection() { + $reader = new IniReader($this->path); + $config = $reader->read('no_section.ini'); + + $expected = array( + 'some_key' => 'some_value', + 'bool_key' => true + ); + $this->assertEquals($config, $expected); + } + /** * test that names with .'s get exploded into arrays. * diff --git a/cake/tests/test_app/config/no_section.ini b/cake/tests/test_app/config/no_section.ini new file mode 100644 index 00000000000..6e6fbb7a04d --- /dev/null +++ b/cake/tests/test_app/config/no_section.ini @@ -0,0 +1,2 @@ +some_key = some_value +bool_key = 1