Issue Type: Patch Created: 2009-01-14T05:17:33.000+0000 Last Updated: 2009-02-26T14:22:33.000+0000 Status: Resolved Fix version(s): - 1.7.6 (02/Mar/09)
Reporter: Bart McLeod (firstname.lastname@example.org) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Config_Writer
Related issues: Attachments: - zf-5544.patch
Catchable fatal error: Argument 1 passed to Zend_Config_Writer_Ini::_addBranch() must be an instance of Zend_Config, string given, called in D:\ZendFramework\library\Zend\Config\Writer\Ini.php on line 119 and defined in D:\ZendFramework\library\Zend\Config\Writer\Ini.php on line 138.
This error is triggered when using Zend_Config_Writer_Ini following the third example in the manual
<pre class="highlight"> $writer->write( 'example.ini', $config);
Where $config is a Zend_Config.
This happens because the code expects a section and doesn't account for no sections at all. In fact, the config should have at least one section for the writer to function properly.
However, this example in the manual: "Example 7.1. Using Zend_Config Per Se" shows us that it is possible to have configuration values that are not part of a section.
It is also possible to read config.ini files that contain no sections at all using Zend_Config_Ini.
I think the behavior of Zend_Config_Writer_Ini should be the inverse of Zend_Config_Ini in that what you can legally read with the latter can be legally written with the first.
I will write a test with a Zend_Config object as in Example 7.1 and see if Zend_Config_Ini_Writer will write it properly. If it doesn't it should be fixed.
Posted by Bart McLeod (email@example.com) on 2009-01-14T05:53:04.000+0000
I attached a patch, that solves this issue and does not break the test.
I do yet have to add a test to avoid regression and I would appreciate if the community would test my patch to see if it still writes other configurations correctly.
Posted by Bart McLeod (firstname.lastname@example.org) on 2009-01-14T05:55:45.000+0000
Changed Issue type to Patch.
Posted by Ben Scholzen (dasprid) on 2009-02-26T14:22:33.000+0000
Fixed with r14175 and merged into 1.7 release branch with r14176.
Have you found an issue?
See the Overview section for more details.