diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index e20f8dcfb..7ab9694ce 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -71,6 +71,12 @@ class IniReader implements ConfigReaderInterface { */ public function read($file) { $filename = $this->_path . $file; + if (!file_exists($filename)) { + $filename .= '.ini'; + if (!file_exists($filename)) { + throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($filename, 0, -4), $filename)); + } + } $contents = parse_ini_file($filename, true); if (!empty($this->_section) && isset($contents[$this->_section])) { $values = $this->_parseNestedValues($contents[$this->_section]); diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index c122f0808..acd0f94df 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -57,15 +57,21 @@ class PhpReader implements ConfigReaderInterface { if (strpos($key, '..') !== false) { throw new ConfigureException(__('Cannot load configuration files with ../ in them.')); } + if (substr($key, -4) === '.php') { + $key = substr($key, 0, -4); + } list($plugin, $key) = pluginSplit($key); if ($plugin) { - $file = App::pluginPath($plugin) . 'config' . DS . $key . '.php'; + $file = App::pluginPath($plugin) . 'config' . DS . $key; } else { - $file = $this->_path . $key . '.php'; + $file = $this->_path . $key; } if (!file_exists($file)) { - throw new ConfigureException(__('Could not load configuration file: ') . $file); + $file .= '.php'; + if (!file_exists($file)) { + throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($file, 0, -4), $file)); + } } include $file; if (!isset($config)) { diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index 3db8bb942..4f077873a 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -114,4 +114,15 @@ class IniReaderTest extends CakeTestCase { $this->assertFalse($config['bools']['test_null']); } + +/** + * test read file without extension + * + * @return void + */ + public function testReadingWithoutExtension() { + $reader = new IniReader($this->path); + $config = $reader->read('nested'); + $this->assertTrue($config['bools']['test_on']); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index 63957ea62..a1d3034fc 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -38,6 +38,9 @@ class PhpReaderTest extends CakeTestCase { $values = $reader->read('var_test'); $this->assertEquals('value', $values['Read']); $this->assertEquals('buried', $values['Deep']['Deeper']['Deepest']); + + $values = $reader->read('var_test.php'); + $this->assertEquals('value', $values['Read']); } /** @@ -84,7 +87,9 @@ class PhpReaderTest extends CakeTestCase { ), true); $reader = new PhpReader($this->path); $result = $reader->read('TestPlugin.load'); + $this->assertTrue(isset($result['plugin_load'])); + $result = $reader->read('TestPlugin.load.php'); $this->assertTrue(isset($result['plugin_load'])); } }