Hello Hannes,

Friday, August 8, 2008, 3:57:16 PM, you wrote:

> On Fri, Aug 8, 2008 at 15:21, Marcus Boerger <[EMAIL PROTECTED]> wrote:
>> helly           Fri Aug  8 13:21:52 2008 UTC
>>
>>  Modified files:              (Branch: PHP_5_3)
>>    /ZendEngine2        zend_execute_API.c
>>    /php-src/main       php.h
>>  Log:
>>  - MFH store error handling mode on stack when executing internal
>>    or overloaded functions and methods. [...]
>>
>>
>> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.331.2.20.2.24.2.50&r2=1.331.2.20.2.24.2.51&diff_format=u
>> Index: ZendEngine2/zend_execute_API.c
>> diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.50 
>> ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.51
>> --- ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.50 Fri Aug  1 14:22:03 
>> 2008
>> +++ ZendEngine2/zend_execute_API.c      Fri Aug  8 13:21:52 2008
>> @@ -17,7 +17,7 @@
>>    +----------------------------------------------------------------------+
>>  */
>>
>> -/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.50 2008/08/01 14:22:03 
>> dmitry Exp $ */
>> +/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.51 2008/08/08 13:21:52 helly 
>> Exp $ */
>>
>>  #include <stdio.h>
>>  #include <signal.h>
>> @@ -890,12 +890,16 @@
>>                EG(opline_ptr) = original_opline_ptr;
>>        } else if (EX(function_state).function->type == 
>> ZEND_INTERNAL_FUNCTION) {
>>                int call_via_handler = 
>> (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) 
>> != 0;
>> +               zend_error_handling_t  error_handling  = EG(error_handling);
>> +               zend_class_entry      *exception_class = EG(exception_class);
>>
>>                ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
>>                if (EX(function_state).function->common.scope) {
>>                        EG(scope) = EX(function_state).function->common.scope;
>>                }
>>                ((zend_internal_function *) 
>> EX(function_state).function)->handler(fci->param_count, 
>> *fci->retval_ptr_ptr, fci->retval_ptr_ptr, 
>> (fci->object_pp?*fci->object_pp:NULL), 1 TSRMLS_CC);
>> +               EG(error_handling)  = error_handling;
>> +               EG(exception_class) = exception_class;
>>                /*  We shouldn't fix bad extensions here,
>>                        because it can break proper ones (Bug #34045)
>>                if (!EX(function_state).function->common.return_reference)
>> @@ -912,12 +916,15 @@
>>                        fci_cache->initialized = 0;
>>                }
>>        } else { /* ZEND_OVERLOADED_FUNCTION */
>> -
>>                ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
>>
>> -                       /* Not sure what should be done here if it's a 
>> static method */
>> +               /* Not sure what should be done here if it's a static method 
>> */
>>                if (fci->object_pp) {
>> +                       zend_error_handling_t  error_handling  = 
>> EG(error_handling);
>> +                       zend_class_entry      *exception_class = 
>> EG(exception_class);
>>                        
>> Z_OBJ_HT_PP(fci->object_pp)->call_method(EX(function_state).function->common.function_name,
>>  fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, 
>> *fci->object_pp, 1 TSRMLS_CC);
>> +                       EG(error_handling)  = error_handling;
>> +                       EG(exception_class) = exception_class;
>>                } else {
>>                        zend_error_noreturn(E_ERROR, "Cannot call overloaded 
>> function for non-object");
>>                }
>> http://cvs.php.net/viewvc.cgi/php-src/main/php.h?r1=1.221.2.4.2.8.2.5&r2=1.221.2.4.2.8.2.6&diff_format=u
>> Index: php-src/main/php.h
>> diff -u php-src/main/php.h:1.221.2.4.2.8.2.5 
>> php-src/main/php.h:1.221.2.4.2.8.2.6
>> --- php-src/main/php.h:1.221.2.4.2.8.2.5        Tue Jun 24 05:59:53 2008
>> +++ php-src/main/php.h  Fri Aug  8 13:21:52 2008
>> @@ -17,7 +17,7 @@
>>    +----------------------------------------------------------------------+
>>  */
>>
>> -/* $Id: php.h,v 1.221.2.4.2.8.2.5 2008/06/24 05:59:53 kalle Exp $ */
>> +/* $Id: php.h,v 1.221.2.4.2.8.2.6 2008/08/08 13:21:52 helly Exp $ */
>>
>>  #ifndef PHP_H
>>  #define PHP_H
>> @@ -288,7 +288,7 @@
>>
>>  BEGIN_EXTERN_C()
>>  PHPAPI void php_set_error_handling(error_handling_t error_handling, 
>> zend_class_entry *exception_class TSRMLS_DC);
>> -#define php_std_error_handling() php_set_error_handling(EH_NORMAL, NULL 
>> TSRMLS_CC)
>> +static ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}

> This doesn't look right...

> $ sapi/cli/php -r 'try { new DOMAttr();} catch(Exception $e) {} strpos();'

> Fatal error: Uncaught exception 'DOMException' with message 'strpos()
> expects at least 2 parameters, 0 given' in Command line code:1

I figured out that the VM has a short path through this and needed to
change that as well. We further more realized that the easiy solution won't
work for all cases anyway. So I provided a full version with save, replace
and restore function that Etienne and I will be using to replace all
php_*_error_handling() calls. Once agina a time when one thinks, cool I
found an easy solution and quite soon gets disillusioned.


Best regards,
 Marcus


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to