ZF-4002: Zend_Config_Ini doesn't restore error handler, Zend_Loader::isReadable throw a Exception
Description
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
restore_error_handler();
But apparently the function restore_error_handler doesn't works good, because the next use of Zend_Loader::isReadable throws an exception.
For example:
<?php
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
Comments
Posted by julien PAULI (doctorrock83) on 2008-08-22T03:31:04.000+0000
Ok I got it. restore_error_handler() should be used in the parseIniFileErrorHandler(), like this :
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 :
Rob, what do you think about that ?
Posted by julien PAULI (doctorrock83) on 2008-08-22T03:37:03.000+0000
I found it : http://bugs.php.net/bug.php?id=31675 ; it's a feature.
Posted by Matthew Weier O'Phinney (matthew) on 2008-08-22T14:52:44.000+0000
Julien -- can this issue be closed, then?
Posted by julien PAULI (doctorrock83) on 2008-08-22T16:16:06.000+0000
Well, I can fix it if needed
Posted by Rob Allen (rob) on 2008-08-23T11:32:24.000+0000
Sorry, was on holiday.
Julien, if you can fix sooner than I can, please do so!
Rob...
Posted by julien PAULI (doctorrock83) on 2008-08-23T11:41:15.000+0000
Ok I patch that next week
Posted by julien PAULI (doctorrock83) on 2008-08-28T08:13:39.000+0000
r11107 is the fix
Posted by Rob Allen (rob) on 2008-08-28T08:29:07.000+0000
Thanks Julien!
For reference, the fix on the release-1.6 branch is r11108.
Regards,
Rob...
Posted by Alexander Veremyev (alexander) on 2008-08-31T03:21:26.000+0000
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.
Posted by Alexander Veremyev (alexander) on 2008-08-31T03:49:47.000+0000
Fixed for the trunk and release-1.6 branch (r11165 and r11166).
Posted by Alexander Veremyev (alexander) on 2008-08-31T06:53:03.000+0000
issue still produces unit tests problems (see [ZF-4139])
Posted by Alexander Veremyev (alexander) on 2008-08-31T10:28:22.000+0000
Problem is actually fixed now, but it de-masked another problem (see [ZF-4139]).
Posted by Alexander Veremyev (alexander) on 2008-09-01T02:50:08.000+0000
Done.
Posted by Wil Sinclair (wil) on 2008-09-02T10:39:04.000+0000
Updating for the 1.6.0 release.