Zend Framework

Make Zend_config_Ini and Zend_Config_Xml test if the file passed to them is readable

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: None
  • Fix Version/s: 1.0.3
  • Component/s: Zend_Config
  • Labels:
    None

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');
        }
(...)

Activity

Hide
Rob Allen added a comment -

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

Show
Rob Allen added a comment - Fixed in svn 6909 (trunk) and 6910 (release-1.0 branch)
Hide
Rob Allen added a comment -

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

Show
Rob Allen added a comment - Re-opened - is_readable() broke BC (see ZF-2232)
Hide
Rob Allen added a comment -

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?

Show
Rob Allen added a comment - 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?
Hide
julien PAULI added a comment -

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

Show
julien PAULI added a comment - Yes Rob, that's the patch I think. I forgot about that *** include path
Hide
Rob Allen added a comment -

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...

Show
Rob Allen added a comment - 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...
Hide
Wil Sinclair added a comment -

Updating Fix Version to follow issue tracker conventions.

Show
Wil Sinclair added a comment - Updating Fix Version to follow issue tracker conventions.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: