[PHP-CVS] cvs: php-src(PHP_5_3) / NEWS /ext/spl php_spl.c /ext/spl/tests spl_autoload_013.phpt spl_autoload_014.phpt spl_autoload_bug48541.phpt
cseiler Tue Jun 30 17:14:38 2009 UTC Added files: (Branch: PHP_5_3) /php-src/ext/spl/tests spl_autoload_013.phpt spl_autoload_014.phpt Modified files: /php-srcNEWS /php-src/ext/splphp_spl.c /php-src/ext/spl/tests spl_autoload_bug48541.phpt Log: MFH: spl_autoload_unregister/spl_autoload_functions and closures http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.659r2=1.2027.2.547.2.965.2.660diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.659 php-src/NEWS:1.2027.2.547.2.965.2.660 --- php-src/NEWS:1.2027.2.547.2.965.2.659 Tue Jun 30 16:17:30 2009 +++ php-src/NEWSTue Jun 30 17:14:37 2009 @@ -2,6 +2,9 @@ ||| ?? ??? 2009, PHP 5.3.1 +- Fixed spl_autoload_unregister/spl_autoad_functions wrt. Closures and + Functors. (Christian Seiler) + - Fixed bug #48681 (openssl signature verification for tar archives broken). (Greg) - Fixed bug #47351 (Memory leak in DateTime). (Derick, Tobias John) http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.38r2=1.52.2.28.2.17.2.39diff_format=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.38 php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.39 --- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.38 Sat Jun 13 17:30:50 2009 +++ php-src/ext/spl/php_spl.c Tue Jun 30 17:14:37 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_spl.c,v 1.52.2.28.2.17.2.38 2009/06/13 17:30:50 cellog Exp $ */ +/* $Id: php_spl.c,v 1.52.2.28.2.17.2.39 2009/06/30 17:14:37 cseiler Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -509,10 +509,10 @@ alfi.closure = zcallable; Z_ADDREF_P(zcallable); - lc_name = erealloc(lc_name, func_name_len + 2 + sizeof(zcallable-value.obj.handle)); - memcpy(lc_name + func_name_len, (zcallable-value.obj.handle), - sizeof(zcallable-value.obj.handle)); - func_name_len += sizeof(zcallable-value.obj.handle); + lc_name = erealloc(lc_name, func_name_len + 2 + sizeof(zend_object_handle)); + memcpy(lc_name + func_name_len, Z_OBJ_HANDLE_P(zcallable), + sizeof(zend_object_handle)); + func_name_len += sizeof(zend_object_handle); lc_name[func_name_len] = '\0'; } @@ -579,6 +579,7 @@ { char *func_name, *error = NULL; int func_name_len; + char *lc_name = NULL; zval *zcallable; int success = FAILURE; zend_function *spl_func_ptr; @@ -604,10 +605,20 @@ efree(error); } - zend_str_tolower(func_name, func_name_len); + lc_name = safe_emalloc(func_name_len, 1, sizeof(long) + 1); + zend_str_tolower_copy(lc_name, func_name, func_name_len); + efree(func_name); + + if (Z_TYPE_P(zcallable) == IS_OBJECT) { + lc_name = erealloc(lc_name, func_name_len + 2 + sizeof(zend_object_handle)); + memcpy(lc_name + func_name_len, Z_OBJ_HANDLE_P(zcallable), + sizeof(zend_object_handle)); + func_name_len += sizeof(zend_object_handle); + lc_name[func_name_len] = '\0'; + } if (SPL_G(autoload_functions)) { - if (func_name_len == sizeof(spl_autoload_call)-1 !strcmp(func_name, spl_autoload_call)) { + if (func_name_len == sizeof(spl_autoload_call)-1 !strcmp(lc_name, spl_autoload_call)) { /* remove all */ zend_hash_destroy(SPL_G(autoload_functions)); FREE_HASHTABLE(SPL_G(autoload_functions)); @@ -616,16 +627,16 @@ success = SUCCESS; } else { /* remove specific */ - success = zend_hash_del(SPL_G(autoload_functions), func_name, func_name_len+1); + success = zend_hash_del(SPL_G(autoload_functions), lc_name, func_name_len+1); if (success != SUCCESS obj_ptr) { - func_name = erealloc(func_name, func_name_len + 1 + sizeof(zend_object_handle)); - memcpy(func_name + func_name_len, Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_object_handle)); + lc_name = erealloc(lc_name, func_name_len + 2 + sizeof(zend_object_handle)); + memcpy(lc_name + func_name_len, Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_object_handle)); func_name_len += sizeof(zend_object_handle); - func_name[func_name_len] = '\0
[PHP-CVS] cvs: php-src(PHP_5_3) /main output.c
cseiler Wed Mar 25 23:59:45 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/main output.c Log: - Fixed memory leak in ob_get_clean/ob_get_flush. # Not necessary in HEAD because output buffering was completely rewritten # there. http://cvs.php.net/viewvc.cgi/php-src/main/output.c?r1=1.167.2.3.2.4.2.12r2=1.167.2.3.2.4.2.13diff_format=u Index: php-src/main/output.c diff -u php-src/main/output.c:1.167.2.3.2.4.2.12 php-src/main/output.c:1.167.2.3.2.4.2.13 --- php-src/main/output.c:1.167.2.3.2.4.2.12Fri Feb 13 11:48:17 2009 +++ php-src/main/output.c Wed Mar 25 23:59:45 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: output.c,v 1.167.2.3.2.4.2.12 2009/02/13 11:48:17 davidc Exp $ */ +/* $Id: output.c,v 1.167.2.3.2.4.2.13 2009/03/25 23:59:45 cseiler Exp $ */ #include php.h #include ext/standard/head.h @@ -867,10 +867,12 @@ /* error checks */ if (!OG(ob_nesting_level)) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete and flush buffer. No buffer to delete or flush.); + zval_dtor(return_value); RETURN_FALSE; } if (OG(ob_nesting_level) !OG(active_ob_buffer).status !OG(active_ob_buffer).erase) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete buffer %s., OG(active_ob_buffer).handler_name); + zval_dtor(return_value); RETURN_FALSE; } /* flush */ @@ -892,10 +894,12 @@ /* error checks */ if (!OG(ob_nesting_level)) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete buffer. No buffer to delete.); + zval_dtor(return_value); RETURN_FALSE; } if (OG(ob_nesting_level) !OG(active_ob_buffer).status !OG(active_ob_buffer).erase) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete buffer %s., OG(active_ob_buffer).handler_name); + zval_dtor(return_value); RETURN_FALSE; } /* delete buffer */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /main output.c
cseiler Thu Mar 26 00:00:18 2009 UTC Modified files: (Branch: PHP_5_2) /php-srcNEWS /php-src/main output.c Log: MFB: Fixed memory leak in ob_get_clean/ob_get_flush. http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1449r2=1.2027.2.547.2.1450diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.1449 php-src/NEWS:1.2027.2.547.2.1450 --- php-src/NEWS:1.2027.2.547.2.1449Wed Mar 25 18:53:04 2009 +++ php-src/NEWSThu Mar 26 00:00:18 2009 @@ -5,6 +5,7 @@ and CURLPROTO_* for redirect fixes in CURL 7.19.4. (Yoram Bar Haim, Stas) - Fixed memory corruptions while reading properties of zip files. (Ilia) +- Fixed memory leak in ob_get_clean/ob_get_flush. (Christian) - Fixed bug #47772 (FILTER_VALIDATE_EMAIL allows f...@bar. addresses). (Ilia) - Fixed bug #47721 (Alignment issues in mbstring and sysvshm extension) http://cvs.php.net/viewvc.cgi/php-src/main/output.c?r1=1.167.2.3.2.8r2=1.167.2.3.2.9diff_format=u Index: php-src/main/output.c diff -u php-src/main/output.c:1.167.2.3.2.8 php-src/main/output.c:1.167.2.3.2.9 --- php-src/main/output.c:1.167.2.3.2.8 Wed Dec 31 11:17:47 2008 +++ php-src/main/output.c Thu Mar 26 00:00:18 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: output.c,v 1.167.2.3.2.8 2008/12/31 11:17:47 sebastian Exp $ */ +/* $Id: output.c,v 1.167.2.3.2.9 2009/03/26 00:00:18 cseiler Exp $ */ #include php.h #include ext/standard/head.h @@ -855,10 +855,12 @@ /* error checks */ if (!OG(ob_nesting_level)) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete and flush buffer. No buffer to delete or flush.); + zval_dtor(return_value); RETURN_FALSE; } if (OG(ob_nesting_level) !OG(active_ob_buffer).status !OG(active_ob_buffer).erase) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete buffer %s., OG(active_ob_buffer).handler_name); + zval_dtor(return_value); RETURN_FALSE; } /* flush */ @@ -880,10 +882,12 @@ /* error checks */ if (!OG(ob_nesting_level)) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete buffer. No buffer to delete.); + zval_dtor(return_value); RETURN_FALSE; } if (OG(ob_nesting_level) !OG(active_ob_buffer).status !OG(active_ob_buffer).erase) { php_error_docref(ref.outcontrol TSRMLS_CC, E_NOTICE, failed to delete buffer %s., OG(active_ob_buffer).handler_name); + zval_dtor(return_value); RETURN_FALSE; } /* delete buffer */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/reflection php_reflection.c
cseiler Sun Feb 1 15:06:20 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/reflection php_reflection.c Log: Fixed regression of bug #46205, thanks to felipe for pointing this out. http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.52r2=1.164.2.33.2.45.2.53diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.52 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.53 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.52Mon Jan 26 22:54:33 2009 +++ php-src/ext/reflection/php_reflection.c Sun Feb 1 15:06:19 2009 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.52 2009/01/26 22:54:33 cseiler Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.53 2009/02/01 15:06:19 cseiler Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2077,6 +2077,9 @@ } efree(fptr); } + if (is_closure) { + zval_ptr_dtor(reference); + } _DO_THROW(The parameter specified by its offset could not be found); /* returns out of this function */ } @@ -2098,6 +2101,9 @@ } efree(fptr); } + if (is_closure) { + zval_ptr_dtor(reference); + } _DO_THROW(The parameter specified by its name could not be found); /* returns out of this function */ } @@ -5429,7 +5435,7 @@ php_info_print_table_start(); php_info_print_table_header(2, Reflection, enabled); - php_info_print_table_row(2, Version, $Revision: 1.164.2.33.2.45.2.52 $); + php_info_print_table_row(2, Version, $Revision: 1.164.2.33.2.45.2.53 $); php_info_print_table_end(); } /* }}} */ @@ -5443,7 +5449,7 @@ NULL, NULL, PHP_MINFO(reflection), - $Revision: 1.164.2.33.2.45.2.52 $, + $Revision: 1.164.2.33.2.45.2.53 $, STANDARD_MODULE_PROPERTIES }; /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/reflection php_reflection.c /ext/reflection/tests 027.phpt ReflectionFunction_getClosure_basic.phpt ReflectionFunction_getClosure_error.phpt ReflectionMethod_getC
cseiler Mon Jan 26 22:54:41 2009 UTC Removed files: (Branch: PHP_5_3) /ZendEngine2/tests closure_005.phpt closure_007.phpt /php-src/ext/reflection/tests 027.phpt ReflectionFunction_getClosure_basic.phpt ReflectionFunction_getClosure_error.phpt ReflectionMethod_getClosure_basic.phpt ReflectionMethod_getClosure_error.phpt closures_004.phpt Modified files: /ZendEngine2zend_closures.c zend_closures.h zend_compile.c zend_compile.h zend_language_parser.y zend_vm_def.h zend_vm_execute.h /ZendEngine2/tests closure_020.phpt closure_026.phpt closure_032.phpt /php-src/ext/reflection php_reflection.c /php-src/ext/reflection/tests closures_001.phpt closures_002.phpt closures_003.phpt Log: [DOC] Remove $this support in closures for PHP 5.3 beta 1 - Implementation notes here: http://wiki.php.net/rfc/closures/removal-of-this http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.c?r1=1.3.2.25r2=1.3.2.26diff_format=u Index: ZendEngine2/zend_closures.c diff -u ZendEngine2/zend_closures.c:1.3.2.25 ZendEngine2/zend_closures.c:1.3.2.26 --- ZendEngine2/zend_closures.c:1.3.2.25Wed Jan 14 10:28:22 2009 +++ ZendEngine2/zend_closures.c Mon Jan 26 22:54:18 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: zend_closures.c,v 1.3.2.25 2009/01/14 10:28:22 dmitry Exp $ */ +/* $Id: zend_closures.c,v 1.3.2.26 2009/01/26 22:54:18 cseiler Exp $ */ #include zend.h #include zend_API.h @@ -37,7 +37,6 @@ typedef struct _zend_closure { zend_objectstd; zend_function func; - zval *this_ptr; } zend_closure; /* non-static since it needs to be referenced */ @@ -111,13 +110,6 @@ } /* }}} */ -ZEND_API zval* zend_get_closure_this_ptr(zval *obj TSRMLS_DC) /* {{{ */ -{ - zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC); - return closure-this_ptr; -} -/* }}} */ - static zend_function *zend_closure_get_method(zval **object_ptr, char *method_name, int method_len TSRMLS_DC) /* {{{ */ { char *lc_name; @@ -187,10 +179,6 @@ destroy_op_array(closure-func.op_array TSRMLS_CC); } - if (closure-this_ptr) { - zval_ptr_dtor(closure-this_ptr); - } - efree(closure); } /* }}} */ @@ -223,17 +211,10 @@ closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC); *fptr_ptr = closure-func; - if (closure-this_ptr) { - if (zobj_ptr) { - *zobj_ptr = closure-this_ptr; - } - *ce_ptr = Z_OBJCE_P(closure-this_ptr); - } else { - if (zobj_ptr) { - *zobj_ptr = NULL; - } - *ce_ptr = closure-func.common.scope; + if (zobj_ptr) { + *zobj_ptr = NULL; } + *ce_ptr = NULL; return SUCCESS; } /* }}} */ @@ -248,13 +229,6 @@ *is_temp = 1; ALLOC_HASHTABLE(rv); zend_hash_init(rv, 1, NULL, ZVAL_PTR_DTOR, 0); - val = closure-this_ptr; - if (!val) { - ALLOC_INIT_ZVAL(val); - } else { - Z_ADDREF_P(val); - } - zend_symtable_update(rv, this, sizeof(this), (void *) val, sizeof(zval *), NULL); if (closure-func.type == ZEND_USER_FUNCTION closure-func.op_array.static_variables) { HashTable *static_variables = closure-func.op_array.static_variables; MAKE_STD_ZVAL(val); @@ -369,7 +343,7 @@ } /* }}} */ -ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zval *this_ptr TSRMLS_DC) /* {{{ */ +ZEND_API void zend_create_closure(zval *res, zend_function *func TSRMLS_DC) /* {{{ */ { zend_closure *closure; @@ -390,19 +364,7 @@ (*closure-func.op_array.refcount)++; } - closure-func.common.scope = scope; - if (scope) { - closure-func.common.fn_flags |= ZEND_ACC_PUBLIC; - if (this_ptr (closure-func.common.fn_flags ZEND_ACC_STATIC) == 0) { - closure-this_ptr = this_ptr; - Z_ADDREF_P(this_ptr); - } else { - closure-func.common.fn_flags |= ZEND_ACC_STATIC; - closure-this_ptr = NULL; - } - } else { - closure-this_ptr = NULL; - } + closure-func.common.scope = NULL; } /* }}} */
[PHP-CVS] Re: cvs: php-src /ext/posix/tests posix_getcwd.phpt posix_getgrnam.phpt posix_getpwnam.phpt posix_getrlimit.phpt posix_initgroups.phpt posix_isatty.phpt posix_mknod.phpt
Hi Felipe, --SKIP-- ?php if (!posix_mknod('posix_getcwd')) die('skip posix_getcwd() not found'); ? ?php if (!posix_mknod('posix_isatty')) die('skip posix_isatty() not found'); ? ?php if (!posix_mknod('posix_mknod')) die('skip posix_mknod() not found'); ? Shouldn't those be function_exists instead of posix_mknod? Regards, Christian -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard basic_functions.c config.m4 math.c php_math.h /ext/standard/tests/math round_large_exp.phpt round_modes.phpt round_prerounding.phpt
cseiler Tue Dec 2 16:25:06 2008 UTC Added files: /php-src/ext/standard/tests/mathround_large_exp.phpt round_modes.phpt round_prerounding.phpt Modified files: /php-src/ext/standard basic_functions.c config.m4 math.c php_math.h Log: - Implemented http://wiki.php.net/rfc/rounding http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.942r2=1.943diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.942 php-src/ext/standard/basic_functions.c:1.943 --- php-src/ext/standard/basic_functions.c:1.942Sat Nov 29 00:47:51 2008 +++ php-src/ext/standard/basic_functions.c Tue Dec 2 16:25:06 2008 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.942 2008/11/29 00:47:51 stas Exp $ */ +/* $Id: basic_functions.c,v 1.943 2008/12/02 16:25:06 cseiler Exp $ */ #include php.h #include php_streams.h @@ -1619,6 +1619,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_round, 0, 0, 1) ZEND_ARG_INFO(0, number) ZEND_ARG_INFO(0, precision) + ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_sin, 0) @@ -3553,6 +3554,11 @@ REGISTER_DOUBLE_CONSTANT(INF, php_get_inf(), CONST_CS | CONST_PERSISTENT); REGISTER_DOUBLE_CONSTANT(NAN, php_get_nan(), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_UP, PHP_ROUND_HALF_UP, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_DOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_EVEN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_ODD, PHP_ROUND_HALF_ODD, CONST_CS | CONST_PERSISTENT); + #if ENABLE_TEST_CLASS test_class_startup(); #endif http://cvs.php.net/viewvc.cgi/php-src/ext/standard/config.m4?r1=1.92r2=1.93diff_format=u Index: php-src/ext/standard/config.m4 diff -u php-src/ext/standard/config.m4:1.92 php-src/ext/standard/config.m4:1.93 --- php-src/ext/standard/config.m4:1.92 Mon Aug 25 13:42:46 2008 +++ php-src/ext/standard/config.m4 Tue Dec 2 16:25:06 2008 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.92 2008/08/25 13:42:46 jani Exp $ -*- autoconf -*- +dnl $Id: config.m4,v 1.93 2008/12/02 16:25:06 cseiler Exp $ -*- autoconf -*- divert(3)dnl @@ -223,31 +223,6 @@ divert(5)dnl dnl -dnl round fuzz -dnl -AC_MSG_CHECKING([whether rounding works as expected]) -AC_TRY_RUN([ -#include math.h - /* keep this out-of-line to prevent use of gcc inline floor() */ - double somefn(double n) { -return floor(n*pow(10,2) + 0.5); - } - int main() { -return somefn(0.045)/10.0 != 0.5; - } -],[ - PHP_ROUND_FUZZ=0.5 - AC_MSG_RESULT(yes) -],[ - PHP_ROUND_FUZZ=0.501 - AC_MSG_RESULT(no) -],[ - PHP_ROUND_FUZZ=0.501 - AC_MSG_RESULT(cross compile) -]) -AC_DEFINE_UNQUOTED(PHP_ROUND_FUZZ, $PHP_ROUND_FUZZ, [ see #24142 ]) - -dnl dnl Check if there is a support means of creating a new process dnl and defining which handles it receives dnl http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.149r2=1.150diff_format=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.149 php-src/ext/standard/math.c:1.150 --- php-src/ext/standard/math.c:1.149 Wed Oct 29 21:43:30 2008 +++ php-src/ext/standard/math.c Tue Dec 2 16:25:06 2008 @@ -19,69 +19,186 @@ +--+ */ -/* $Id: math.c,v 1.149 2008/10/29 21:43:30 felixdv Exp $ */ +/* $Id: math.c,v 1.150 2008/12/02 16:25:06 cseiler Exp $ */ #include php.h #include php_math.h #include zend_multiply.h +#include zend_float.h #include math.h #include float.h #include stdlib.h +/* {{{ php_intlog10abs + Returns floor(log10(fabs(val))), uses fast binary search */ +static inline int php_intlog10abs(double value) { + int result; + value = fabs(value); + + if (value 1e-8 || value 1e23) { + result = (int)floor(log10(value)); + } else { + static const double values[] = { + 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, + 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, + 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; + /* Do a binary search with 5 steps */ + result = 16; + if (value values[result]) { + result -= 8; + } else { + result += 8; + } + if (value values[result]) { + result -= 4; + } else { + result += 4; + } +
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard basic_functions.c config.m4 math.c php_math.h /ext/standard/tests/math round_large_exp.phpt round_modes.phpt round_prerounding.phpt
cseiler Tue Dec 2 16:27:15 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/standard/tests/mathround_large_exp.phpt round_modes.phpt round_prerounding.phpt Modified files: /php-src/ext/standard basic_functions.c config.m4 math.c php_math.h Log: - MFH: Implemented http://wiki.php.net/rfc/rounding http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.64.2.77r2=1.725.2.31.2.64.2.78diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.77 php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.78 --- php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.77 Sat Nov 29 00:44:33 2008 +++ php-src/ext/standard/basic_functions.c Tue Dec 2 16:27:14 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.77 2008/11/29 00:44:33 stas Exp $ */ +/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.78 2008/12/02 16:27:14 cseiler Exp $ */ #include php.h #include php_streams.h @@ -1632,6 +1632,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_round, 0, 0, 1) ZEND_ARG_INFO(0, number) ZEND_ARG_INFO(0, precision) + ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_sin, 0) @@ -3571,6 +3572,11 @@ REGISTER_DOUBLE_CONSTANT(INF, php_get_inf(), CONST_CS | CONST_PERSISTENT); REGISTER_DOUBLE_CONSTANT(NAN, php_get_nan(), CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_UP, PHP_ROUND_HALF_UP, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_DOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_EVEN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PHP_ROUND_HALF_ODD, PHP_ROUND_HALF_ODD, CONST_CS | CONST_PERSISTENT); + #if ENABLE_TEST_CLASS test_class_startup(); #endif http://cvs.php.net/viewvc.cgi/php-src/ext/standard/config.m4?r1=1.80.2.3.2.3.2.6r2=1.80.2.3.2.3.2.7diff_format=u Index: php-src/ext/standard/config.m4 diff -u php-src/ext/standard/config.m4:1.80.2.3.2.3.2.6 php-src/ext/standard/config.m4:1.80.2.3.2.3.2.7 --- php-src/ext/standard/config.m4:1.80.2.3.2.3.2.6 Mon Aug 25 13:42:54 2008 +++ php-src/ext/standard/config.m4 Tue Dec 2 16:27:15 2008 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.80.2.3.2.3.2.6 2008/08/25 13:42:54 jani Exp $ -*- autoconf -*- +dnl $Id: config.m4,v 1.80.2.3.2.3.2.7 2008/12/02 16:27:15 cseiler Exp $ -*- autoconf -*- divert(3)dnl @@ -223,31 +223,6 @@ divert(5)dnl dnl -dnl round fuzz -dnl -AC_MSG_CHECKING([whether rounding works as expected]) -AC_TRY_RUN([ -#include math.h - /* keep this out-of-line to prevent use of gcc inline floor() */ - double somefn(double n) { -return floor(n*pow(10,2) + 0.5); - } - int main() { -return somefn(0.045)/10.0 != 0.5; - } -],[ - PHP_ROUND_FUZZ=0.5 - AC_MSG_RESULT(yes) -],[ - PHP_ROUND_FUZZ=0.501 - AC_MSG_RESULT(no) -],[ - PHP_ROUND_FUZZ=0.501 - AC_MSG_RESULT(cross compile) -]) -AC_DEFINE_UNQUOTED(PHP_ROUND_FUZZ, $PHP_ROUND_FUZZ, [ see #24142 ]) - -dnl dnl Check if there is a support means of creating a new process dnl and defining which handles it receives dnl http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.131.2.2.2.6.2.10r2=1.131.2.2.2.6.2.11diff_format=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.131.2.2.2.6.2.10 php-src/ext/standard/math.c:1.131.2.2.2.6.2.11 --- php-src/ext/standard/math.c:1.131.2.2.2.6.2.10 Wed Oct 29 20:03:34 2008 +++ php-src/ext/standard/math.c Tue Dec 2 16:27:15 2008 @@ -19,70 +19,186 @@ +--+ */ -/* $Id: math.c,v 1.131.2.2.2.6.2.10 2008/10/29 20:03:34 iliaa Exp $ */ +/* $Id: math.c,v 1.131.2.2.2.6.2.11 2008/12/02 16:27:15 cseiler Exp $ */ #include php.h #include php_math.h #include zend_multiply.h +#include zend_float.h #include math.h #include float.h #include stdlib.h +/* {{{ php_intlog10abs + Returns floor(log10(fabs(val))), uses fast binary search */ +static inline int php_intlog10abs(double value) { + int result; + value = fabs(value); + if (value 1e-8 || value 1e23) { + result = (int)floor(log10(value)); + } else { + static const double values[] = { + 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, + 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, + 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; + /* Do a binary search with 5 steps */ + result = 16; + if (value
[PHP-CVS] cvs: php-src(PHP_5_3) / NEWS
cseiler Tue Dec 2 16:28:24 2008 UTC Modified files: (Branch: PHP_5_3) /php-srcNEWS Log: #- Updated NEWS file http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.397r2=1.2027.2.547.2.965.2.398diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.965.2.397 php-src/NEWS:1.2027.2.547.2.965.2.398 --- php-src/NEWS:1.2027.2.547.2.965.2.397 Mon Dec 1 23:30:21 2008 +++ php-src/NEWSTue Dec 2 16:28:24 2008 @@ -9,6 +9,10 @@ - Changed error level E_ERROR into E_WARNING in Soap extension methods parameter validation. (Felipe) - Changed openssl info to show the shared library version number. (Scott) +- Changed floating point behaviour to consistently use double precision on all + platforms and with all compilers. (Christian Seiler) +- Changed round() to act more intuitively when rounding to a certain precision + and to correctly round very large and very small exponents. (Christian Seiler) - Added support for namespaces with brackets. (Greg) - Added stream_cast() and stream_set_options() to user-space stream wrappers, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] Re: cvs: php-src(PHP_5_3) /ext/standard math.c
Hi, Modified files: (Branch: PHP_5_3) /php-src/ext/standard math.c Log: Fixed bug #42294 (Unified solution for round() based on C99 round) [DOC] New implementation of round() to work-around inconsistencies for win32 and 64 bit platforms. This solution is very roughly based on BSD's implmentation of round(), which itself is an implementation of C99 standard. We take the absolute value of number we want to round time the 10 to the power of the number of decimal spaces we are rounding to. The resulting value is rounded up and the pre-rounded value is subtracted from it. If the difference is greater then 0.51 we round up, otherwise we round down. Apparently, nobody reads internals anymore. :-( I made my initial comment on the bug report over a year ago. Since then I've dug quite a bit into floating point arithmetics and the actual problems behind round(). This lead to: http://wiki.php.net/rfc/rounding Which I posted quite a while ago and nearly nobody was interested: http://news.php.net/php.internals/40070 [Now please don't simply apply the patch there, I've done some additional research since.] The solution I proposed over a year ago is actually wrong and it does not solve all the problems of round()'s g, see my RFC for that. The general problems with round are actually: 1) Internal FPU precision on x86. 2) Specification problem (which rounding mode should actually be used?) 3) Dividing/multiplying by = 10^23 is not exact. 4) round (1.255, 2) should give 1.26 but gives 1.25. The FUZZ stuff tries to resolve this issue (but not the other three) but I've come to the conclusion that the FUZZ is actually the wrong solution for the problem. Since I didn't get any reaction on the RFC on internals, I pinged Lukas and Johannes (as they are RMs for PHP 5.3) in private in order to ask whether it was possible to include my proposal in 5.3 (I don't have ZE2 Karma and my patch also needs to change zend_strtod). Lukas and Johannes were concerned about the interopability of my solution of problem (1). So I did some tests on different platforms and operating systems and Lukas and Johannes asked around for other people to do tests, too. I've summarized results of these tests and proposed solution for correct cross-platform floating point arithmetics here: http://www.christian-seiler.de/projekte/fpmath/ I've mailed patches for PHP 5.3 and HEAD to Johannes and Lukas for ZendEngine2 that only address the above issue (1) and do the following: 1) Define some macros for math-related functions that will ensure the function itself always uses double precision. Add configure checks for these macros. 2) Modified zend_strtod and the add/sub/div/mul functions in zend_operators.c to make use of those macros. This ensures that PHP will always use double precision for calculations and math is thus portable. 3) Added a test that determines if the calculations precision is actually correct. The patches for 5.3 and HEAD are found here: http://www.christian-seiler.de/temp/php/2008-10-28-fpu/php-float-precision-5.3.patch http://www.christian-seiler.de/temp/php/2008-10-28-fpu/php-float-precision-6.patch My next step (as discussed with Johannes and Lukas) would have been to apply the Non-ZE2-part of my patch to ext/standard/math.c in 5.3 and HEAD (I don't have separate patches for that yet but they are quite trivial to adapt to the new macros). Now the question is: Where do we go from here? Your commit does not solve all the problems of PHP's round but is at least better than the previous implementation since at least the platform-dependency on whether or not to use the FUZZ is removed. The other problems, however, remain. Christian -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) / NEWS
cseiler Tue Aug 12 21:03:37 2008 UTC Modified files: (Branch: PHP_5_2) /php-srcNEWS Log: - News: http://news.php.net/php.cvs/52239 http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1195r2=1.2027.2.547.2.1196diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.1195 php-src/NEWS:1.2027.2.547.2.1196 --- php-src/NEWS:1.2027.2.547.2.1195Mon Aug 11 22:40:02 2008 +++ php-src/NEWSTue Aug 12 21:03:35 2008 @@ -13,6 +13,8 @@ functions. (Andrey) - Fixed a regression when using strip_tags() and is within an attribute. (Scott) +- Fixed a crash on invalid method in ReflectionParameter constructor. + (Christian Seiler) - Fixed bug #45765 (ReflectionObject with default parameters of self::xxx cause an error). (Felipe) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/reflection php_reflection.c /ext/reflection/tests reflectionParameter_invalidMethodInConstructor.phpt
cseiler Mon Aug 11 22:08:59 2008 UTC Added files: (Branch: PHP_5_2) /php-src/ext/reflection/tests reflectionParameter_invalidMethodInConstructor.phpt Modified files: /php-src/ext/reflection php_reflection.c Log: - Fixed segmentation fault (test added) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.52r2=1.164.2.33.2.53diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.52 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.53 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.52 Mon Aug 11 00:50:02 2008 +++ php-src/ext/reflection/php_reflection.c Mon Aug 11 22:08:58 2008 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.52 2008/08/11 00:50:02 felipe Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.53 2008/08/11 22:08:58 cseiler Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1871,7 +1871,7 @@ if (zend_hash_find(ce-function_table, lcname, lcname_len + 1, (void **) fptr) == FAILURE) { efree(lcname); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - Method %s::%s() does not exist, Z_STRVAL_PP(classref), Z_TYPE_PP(method), Z_STRVAL_PP(method)); + Method %s::%s() does not exist, ce-name, Z_STRVAL_PP(method)); return; } efree(lcname); @@ -4908,7 +4908,7 @@ php_info_print_table_start(); php_info_print_table_header(2, Reflection, enabled); - php_info_print_table_row(2, Version, $Id: php_reflection.c,v 1.164.2.33.2.52 2008/08/11 00:50:02 felipe Exp $); + php_info_print_table_row(2, Version, $Id: php_reflection.c,v 1.164.2.33.2.53 2008/08/11 22:08:58 cseiler Exp $); php_info_print_table_end(); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt?view=markuprev=1.1 Index: php-src/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt +++ php-src/ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/reflection php_reflection.c /ext/reflection/tests closures_003.phpt closures_004.phpt reflectionParameter_invalidMethodInConstructor.phpt
cseiler Mon Aug 11 22:30:44 2008 UTC Added files: /php-src/ext/reflection/tests closures_003.phpt closures_004.phpt Modified files: /php-src/ext/reflection php_reflection.c /php-src/ext/reflection/tests reflectionParameter_invalidMethodInConstructor.phpt Log: - Fixed sefaults (tests added) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.314r2=1.315diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.314 php-src/ext/reflection/php_reflection.c:1.315 --- php-src/ext/reflection/php_reflection.c:1.314 Mon Aug 11 19:34:49 2008 +++ php-src/ext/reflection/php_reflection.c Mon Aug 11 22:30:44 2008 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_reflection.c,v 1.314 2008/08/11 19:34:49 helly Exp $ */ +/* $Id: php_reflection.c,v 1.315 2008/08/11 22:30:44 cseiler Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -228,6 +228,28 @@ } /* }}} */ +static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */ +{ + if (fptr +fptr-type == ZEND_INTERNAL_FUNCTION +(fptr-internal_function.fn_flags ZEND_ACC_CALL_VIA_HANDLER) != 0) + { + zend_function *copy_fptr; + copy_fptr = emalloc(sizeof(zend_function)); + memcpy(copy_fptr, fptr, sizeof(zend_function)); + if (UG(unicode)) { + copy_fptr-internal_function.function_name.u = eustrdup(fptr-internal_function.function_name.u); + } else { + copy_fptr-internal_function.function_name.s = estrdup(fptr-internal_function.function_name.s); + } + return copy_fptr; + } else { + /* no copy needed */ + return fptr; + } +} +/* }}} */ + static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */ { if (fptr @@ -1812,7 +1834,7 @@ zval *parameter; ALLOC_ZVAL(parameter); - reflection_parameter_factory(fptr, arg_info, i, fptr-common.required_num_args, parameter TSRMLS_CC); + reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), arg_info, i, fptr-common.required_num_args, parameter TSRMLS_CC); add_next_index_zval(return_value, parameter); arg_info++; @@ -1956,7 +1978,7 @@ } else if (zend_u_hash_find(ce-function_table, Z_TYPE_PP(method), lcname, lcname_len + 1, (void **) fptr) == FAILURE) { efree(lcname.v); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - Method %R::%R() does not exist, Z_TYPE_PP(classref), Z_UNIVAL_PP(classref), Z_TYPE_PP(method), Z_UNIVAL_PP(method)); + Method %v::%R() does not exist, ce-name, Z_TYPE_PP(method), Z_UNIVAL_PP(method)); return; } efree(lcname.v); @@ -2064,9 +2086,9 @@ GET_REFLECTION_OBJECT_PTR(param); if (!param-fptr-common.scope) { - reflection_function_factory(param-fptr, return_value TSRMLS_CC); + reflection_function_factory(_copy_function(param-fptr TSRMLS_CC), return_value TSRMLS_CC); } else { - reflection_method_factory(param-fptr-common.scope, param-fptr, return_value TSRMLS_CC); + reflection_method_factory(param-fptr-common.scope, _copy_function(param-fptr TSRMLS_CC), return_value TSRMLS_CC); } } /* }}} */ @@ -2458,7 +2480,14 @@ /* Returns from this function */ } - zend_create_closure(return_value, mptr, mptr-common.scope, obj TSRMLS_CC); + /* This is an original closure object and __invoke is to be called. */ + if (Z_OBJCE_P(obj) == zend_ce_closure mptr-type == ZEND_INTERNAL_FUNCTION + (mptr-internal_function.fn_flags ZEND_ACC_CALL_VIA_HANDLER) != 0) + { + RETURN_ZVAL(obj, 1, 0); + } else { + zend_create_closure(return_value, mptr, mptr-common.scope, obj TSRMLS_CC); + } } } /* }}} */ @@ -5394,7 +5423,7 @@ php_info_print_table_start(); php_info_print_table_header(2, Reflection, enabled); - php_info_print_table_row(2, Version, $Id: php_reflection.c,v 1.314 2008/08/11 19:34:49 helly Exp $); + php_info_print_table_row(2, Version, $Id: php_reflection.c,v 1.315 2008/08/11 22:30:44 cseiler Exp $); php_info_print_table_end(); } /* }}} */
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/reflection php_reflection.c /ext/reflection/tests closures_003.phpt closures_004.phpt reflectionParameter_invalidMethodInConstructor.phpt
cseiler Mon Aug 11 22:31:23 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/reflection/tests closures_003.phpt closures_004.phpt reflectionParameter_invalidMethodInConstructor.phpt Modified files: /php-src/ext/reflection php_reflection.c Log: MFH: Fixed segfaults (tests added) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.32r2=1.164.2.33.2.45.2.33diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.32 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.33 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.32Mon Aug 11 19:35:00 2008 +++ php-src/ext/reflection/php_reflection.c Mon Aug 11 22:31:21 2008 @@ -20,7 +20,7 @@ +--+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.32 2008/08/11 19:35:00 helly Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.33 2008/08/11 22:31:21 cseiler Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -231,6 +231,24 @@ class_entry-interfaces[num_interfaces - 1] = interface_entry; } +static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */ +{ + if (fptr +fptr-type == ZEND_INTERNAL_FUNCTION +(fptr-internal_function.fn_flags ZEND_ACC_CALL_VIA_HANDLER) != 0) + { + zend_function *copy_fptr; + copy_fptr = emalloc(sizeof(zend_function)); + memcpy(copy_fptr, fptr, sizeof(zend_function)); + copy_fptr-internal_function.function_name = estrdup(fptr-internal_function.function_name); + return copy_fptr; + } else { + /* no copy needed */ + return fptr; + } +} +/* }}} */ + static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */ { if (fptr @@ -1782,7 +1800,7 @@ zval *parameter; ALLOC_ZVAL(parameter); - reflection_parameter_factory(fptr, arg_info, i, fptr-common.required_num_args, parameter TSRMLS_CC); + reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), arg_info, i, fptr-common.required_num_args, parameter TSRMLS_CC); add_next_index_zval(return_value, parameter); arg_info++; @@ -2033,9 +2051,9 @@ GET_REFLECTION_OBJECT_PTR(param); if (!param-fptr-common.scope) { - reflection_function_factory(param-fptr, return_value TSRMLS_CC); + reflection_function_factory(_copy_function(param-fptr TSRMLS_CC), return_value TSRMLS_CC); } else { - reflection_method_factory(param-fptr-common.scope, param-fptr, return_value TSRMLS_CC); + reflection_method_factory(param-fptr-common.scope, _copy_function(param-fptr TSRMLS_CC), return_value TSRMLS_CC); } } /* }}} */ @@ -2393,7 +2411,14 @@ /* Returns from this function */ } - zend_create_closure(return_value, mptr, mptr-common.scope, obj TSRMLS_CC); + /* This is an original closure object and __invoke is to be called. */ + if (Z_OBJCE_P(obj) == zend_ce_closure mptr-type == ZEND_INTERNAL_FUNCTION + (mptr-internal_function.fn_flags ZEND_ACC_CALL_VIA_HANDLER) != 0) + { + RETURN_ZVAL(obj, 1, 0); + } else { + zend_create_closure(return_value, mptr, mptr-common.scope, obj TSRMLS_CC); + } } } /* }}} */ @@ -5217,7 +5242,7 @@ php_info_print_table_start(); php_info_print_table_header(2, Reflection, enabled); - php_info_print_table_row(2, Version, $Id: php_reflection.c,v 1.164.2.33.2.45.2.32 2008/08/11 19:35:00 helly Exp $); + php_info_print_table_row(2, Version, $Id: php_reflection.c,v 1.164.2.33.2.45.2.33 2008/08/11 22:31:21 cseiler Exp $); php_info_print_table_end(); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/closures_003.phpt?view=markuprev=1.1 Index: php-src/ext/reflection/tests/closures_003.phpt +++ php-src/ext/reflection/tests/closures_003.phpt --TEST-- Reflection on closures: Segfaults with getParameters() and getDeclaringFunction() --FILE-- ?php $closure = function($a, $b = 0) { }; $method = new ReflectionMethod ($closure); $params = $method-getParameters (); unset ($method); $method = $params[0]-getDeclaringFunction (); unset ($params); echo $method-getName ().\n; $parameter = new ReflectionParameter ($closure, 'b'); $method = $parameter-getDeclaringFunction (); unset ($parameter); echo $method-getName ().\n; ? ===DONE=== --EXPECTF-- __invoke __invoke ===DONE===