ZF-2207: Make Zend_config_Ini and Zend_Config_Xml test if the file passed to them is readable

Issue Type: Improvement Created: 2007-11-16T03:46:27.000+0000 Last Updated: 2008-01-23T18:18:36.000+0000 Status: Resolved Fix version(s): - 1.0.3 (30/Nov/07)

Reporter: julien PAULI (doctorrock83) Assignee: Rob Allen (rob) Tags: - Zend_Config

Related issues: Attachments:


Actually, Zend_Config_Ini and Zend_Config_Xml never check if the file you try to access is readable. Instead of that, they try to load it ( respectively by parse_ini_file(), and simplexml_load_file ), thus making a warning appear if the file can't be found or read.

These classes should try to read the file passed to their constructor, before making buz with them, and throw exceptions if there's a problem. Actual Zend_Config_Ini code ( same for Zend_Config_Xml ) :

<pre class="highlight">
public function __construct($filename, $section, $config = false)
        if (empty($filename)) {
            throw new Zend_Config_Exception('Filename is not set');

Improvement :

<pre class="highlight">
public function __construct($filename, $section, $config = false)
        if (empty($filename) || !is_readable($filename)) {
            throw new Zend_Config_Exception('Filename is not set');


Posted by Rob Allen (rob) on 2007-11-23T17:39:43.000+0000

Fixed in svn 6909 (trunk) and 6910 (release-1.0 branch)

Posted by Rob Allen (rob) on 2007-11-25T14:57:53.000+0000

Re-opened - is_readable() broke BC (see ZF-2232)

Posted by Rob Allen (rob) on 2007-11-25T15:00:50.000+0000

To fix this, we'll have to use Zend_Loader::isReadable() which will obviously introduce a dependency for Zend_Config that isn't there at the moment.

Code would be:

<pre class="highlight">
        if (!Zend_Loader::isReadable($filename)) {
            throw new Zend_Config_Exception('Unable to read config file');


Posted by julien PAULI (doctorrock83) on 2007-11-25T15:09:18.000+0000

Yes Rob, that's the patch I think. I forgot about that *** include path ;-)

Posted by Rob Allen (rob) on 2007-11-27T14:24:46.000+0000

Won't fix in 1.x as we don't want to introduce a BC break by using is_readable() or introduce a dependency on Zend_Loader.

Workaround if the notice is a problem is to call Zend_Loader::isReadable() before called Zend_Config_Ini/Zend_Config_Xml.



Posted by Wil Sinclair (wil) on 2008-01-23T18:18:36.000+0000

Updating Fix Version to follow issue tracker conventions.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.