ZF-4002: Zend_Config_Ini doesn't restore error handler, Zend_Loader::isReadable throw a Exception


Zend_Config_ini use a error handler for "convert any warnings into exceptions"

 $old_error_handler = set_error_handler(array('Zend_Config_Ini', 'parseIniFileErrorHandler'));
        $iniArray = parse_ini_file($filename, true); // convert any warnings into exceptions

But apparently the function restore_error_handler doesn't works good, because the next use of Zend_Loader::isReadable throws an exception.

For example:


  include_once ('Zend/Loader.php');
        include_once ('Zend/Config/Ini.php');

        try {
                $config = new Zend_Config_Ini ('errorini', 'errorsection');
        } catch (Exception $e) {
                //Whoa! No error!

        Zend_Loader::isReadable ('errorfile'); // Doesn't returns boolean, instead throws a Zend_Config_Exception


Ok I got it. restore_error_handler() should be used in the parseIniFileErrorHandler(), like this :

public function parseIniFileErrorHandler(....)
     require_once 'Zend/Config/Exception.php';
     throw new Zend_Config_Exception($errstr);

But this seems to bug as well, and seems to be a PHP bug ( or feature ). (PHP 5.2.6) -- restore_error_handler() looks like to be ignored while written in a error handler callback function --

To fix the bug, set_error_handler($oldHandler) works, like this :

public function parseIniFileErrorHandler(....)
     require_once 'Zend/Config/Exception.php';
     throw new Zend_Config_Exception($errstr);

Rob, what do you think about that ?

I found it : ; it's a feature.

Julien -- can this issue be closed, then?

Well, I can fix it if needed

Sorry, was on holiday.

Julien, if you can fix sooner than I can, please do so!


Ok I patch that next week

r11107 is the fix

Thanks Julien!

For reference, the fix on the release-1.6 branch is r11108.



Used solution corrupts error handlers stack.

E.g. source error stack:


will be translated into:

... _loadFileErrorHandler()>

instead of original state.

I'm going to fix it.

Fixed for the trunk and release-1.6 branch (r11165 and r11166).

issue still produces unit tests problems (see [ZF-4139])

Problem is actually fixed now, but it de-masked another problem (see [ZF-4139]).


Updating for the 1.6.0 release.