Issues

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

Issue Type: Bug Created: 2008-08-19T19:12:14.000+0000 Last Updated: 2008-09-02T10:39:04.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Mahomedalid Pacheco (mictlan) Assignee: Alexander Veremyev (alexander) Tags: - Zend_Config

Related issues: - ZF-4139

Attachments:

Description

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

<pre class="highlight">

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

<pre class="highlight">
<?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 :

<pre class="highlight">
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 :

<pre class="highlight">
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 ?

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.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts