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

Description

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 ) :


public function __construct($filename, $section, $config = false)
    {
        if (empty($filename)) {
            throw new Zend_Config_Exception('Filename is not set');
        }
(...)

Improvement :


public function __construct($filename, $section, $config = false)
    {
        if (empty($filename) || !is_readable($filename)) {
            throw new Zend_Config_Exception('Filename is not set');
        }
(...)

Comments

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

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

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:


        if (!Zend_Loader::isReadable($filename)) {
            throw new Zend_Config_Exception('Unable to read config file');
        }

Thoughts?

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

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.

Regards,

Rob...

Updating Fix Version to follow issue tracker conventions.