From: Dmitry Stogov Date: Tue, 26 Sep 2006 07:55:21 +0000 (+0000) Subject: Fixed bug #38942 (Double old-style-ctor inheritance) X-Git-Tag: php-5.2.0RC5~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a04b6ed6bcdda52c3f68199b547b3968bbbadd6c;p=php Fixed bug #38942 (Double old-style-ctor inheritance) --- diff --git a/NEWS b/NEWS index 3ef212bb0c..0d3ac5d6fe 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ PHP NEWS - Fixed mess with CGI/CLI -d option (now it works with cgi; constants are working exactly like in php.ini; with FastCGI -d affects all requests). (Dmitry) +- Fixed bug #38942 (Double old-style-ctor inheritance). (Dmitry) - Fixed bug #38941 (imap extension does not compile against new version of the imap library). (Ilia) - Fixed bug #38904 (apache2filter changes cwd to /). (Ilia, bjori) diff --git a/Zend/tests/bug38942.phpt b/Zend/tests/bug38942.phpt new file mode 100755 index 0000000000..85bb56d200 --- /dev/null +++ b/Zend/tests/bug38942.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #38942 (Double old-style-ctor inheritance) +--FILE-- + +--EXPECT-- +Array +( + [0] => foo +) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 06355a9689..6ae3a0fbd5 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -874,9 +874,21 @@ ZEND_FUNCTION(get_class_methods) instanceof_function(EG(scope), mptr->common.scope TSRMLS_CC)) || ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) && EG(scope) == mptr->common.scope)))) { - MAKE_STD_ZVAL(method_name); - ZVAL_STRING(method_name, mptr->common.function_name, 1); - zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); + char *key; + uint key_len; + ulong num_index; + uint len = strlen(mptr->common.function_name); + + /* Do not display old-style inherited constructors */ + if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || + mptr->common.scope == ce || + zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING || + zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) { + + MAKE_STD_ZVAL(method_name); + ZVAL_STRINGL(method_name, mptr->common.function_name, len, 1); + zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); + } } zend_hash_move_forward_ex(&ce->function_table, &pos); } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index bca4032f99..65ad634949 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -518,8 +518,20 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) { if (!(mptr->common.fn_flags & ZEND_ACC_STATIC)) { - string_printf(str, "\n"); - _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC); + char *key; + uint key_len; + ulong num_index; + uint len = strlen(mptr->common.function_name); + + /* Do not display old-style inherited constructors */ + if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || + mptr->common.scope == ce || + zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING || + zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0) { + + string_printf(str, "\n"); + _function_string(str, mptr, ce, sub_indent.string TSRMLS_CC); + } } zend_hash_move_forward_ex(&ce->function_table, &pos); } diff --git a/ext/reflection/tests/bug38942.phpt b/ext/reflection/tests/bug38942.phpt new file mode 100755 index 0000000000..ce0d806bf4 --- /dev/null +++ b/ext/reflection/tests/bug38942.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #38942 (Double old-style-ctor inheritance) +--FILE-- + +--EXPECTF-- +Class [ class bar extends foo ] { + @@ %sbug38942.php 6-7 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [2] { + Method [ public method foo ] { + @@ %sbug38942.php 3 - 3 + } + } +}