History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-4002
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Alexander Veremyev
Reporter: Mahomedalid Pacheco
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

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

Created: 19/Aug/08 07:12 PM   Updated: 02/Sep/08 10:39 AM
Component/s: Zend_Config
Affects Version/s: 1.6.0RC2, 1.6.0RC1
Fix Version/s: 1.6.0

Time Tracking:
Not Specified

Issue Links:
Related
 

Tags:
Participants: Alexander Veremyev, julien PAULI, Mahomedalid Pacheco, Matthew Weier O'Phinney, Rob Allen and Wil Sinclair


 Description  « Hide
Zend_Config_ini use a error handler for "convert any warnings into exceptions"
Zend_Config_Ini.php / __construct / LOC: 108
$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


 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
julien PAULI - 22/Aug/08 03:31 AM
Ok I got it.
restore_error_handler() should be used in the parseIniFileErrorHandler(), like this :
public function parseIniFileErrorHandler(....)
{
     require_once 'Zend/Config/Exception.php';
     restore_error_handler();
     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';
     set_error_handler($this->old_error_handler);
     throw new Zend_Config_Exception($errstr);
}

Rob, what do you think about that ?


julien PAULI - 22/Aug/08 03:37 AM
I found it : http://bugs.php.net/bug.php?id=31675 ; it's a feature.

Matthew Weier O'Phinney - 22/Aug/08 02:52 PM
Julien – can this issue be closed, then?

julien PAULI - 22/Aug/08 04:16 PM
Well, I can fix it if needed

Rob Allen - 23/Aug/08 11:32 AM
Sorry, was on holiday.

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

Rob...


julien PAULI - 23/Aug/08 11:41 AM
Ok I patch that next week

julien PAULI - 28/Aug/08 08:13 AM
r11107 is the fix

Rob Allen - 28/Aug/08 08:29 AM
Thanks Julien!

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

Regards,

Rob...


Alexander Veremyev - 31/Aug/08 03:21 AM
Used solution corrupts error handlers stack.

E.g. source error stack:
-------------------------------------
<system error handler>
...
<latest user defined error handler>
----------------------------
will be translated into:
-------------------------------------
<system error handler>
...
<latest user defined error handler>
<Zend_Config object->_loadFileErrorHandler()>
<latest user defined error handler>
----------------------------
instead of original state.

I'm going to fix it.


Alexander Veremyev - 31/Aug/08 03:49 AM
Fixed for the trunk and release-1.6 branch (r11165 and r11166).

Alexander Veremyev - 31/Aug/08 06:53 AM
issue still produces unit tests problems (see ZF-4139)

Alexander Veremyev - 31/Aug/08 10:28 AM
Problem is actually fixed now, but it de-masked another problem (see ZF-4139).

Alexander Veremyev - 01/Sep/08 02:50 AM
Done.

Wil Sinclair - 02/Sep/08 10:39 AM
Updating for the 1.6.0 release.