diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-02 11:07:57 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-03 11:55:48 +0100 |
commit | 53efa1b0c69b463ea9d3606d828c036129f2dec9 (patch) | |
tree | c4b2a0e33acce36638f200af3b1add704a2e2e88 /Zend/zend_API.c | |
parent | a7a2e9857e96abc2147e895f8d844a6e73e86170 (diff) | |
download | php-git-53efa1b0c69b463ea9d3606d828c036129f2dec9.tar.gz |
Store aliased name of trait method
Currently, trait methods are aliased will continue to use the
original function name. In a few places in the codebase, we will
try to look up the actual method name instead. However, this does
not work if an aliased method is used indirectly
(https://bugs.php.net/bug.php?id=69180).
I think it would be better to instead actually change the method
name to the alias. This is in principle easy: We have to allow
function_name to be changed even if op array is otherwise shared
(similar to static_variables). This means we need to addref/release
the function_name separately, but I don't think there is a
performance concern here (especially as everything is usually
interned).
There is a bit of complication in opcache, where we need to make
sure that the function name is released the correct number of times
(interning may overwrite the name in the original op_array, but we
need to release it as many times as the op_array is shared).
Fixes bug #69180.
Fixes bug #74939.
Closes GH-5226.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 74afc47474..50a1d434db 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -4228,55 +4228,6 @@ ZEND_API void zend_restore_error_handling(zend_error_handling *saved) /* {{{ */ } /* }}} */ -ZEND_API zend_string* zend_find_alias_name(zend_class_entry *ce, zend_string *name) /* {{{ */ -{ - zend_trait_alias *alias, **alias_ptr; - - if ((alias_ptr = ce->trait_aliases)) { - alias = *alias_ptr; - while (alias) { - if (alias->alias && zend_string_equals_ci(alias->alias, name)) { - return alias->alias; - } - alias_ptr++; - alias = *alias_ptr; - } - } - - return name; -} -/* }}} */ - -ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f) /* {{{ */ -{ - zend_function *func; - HashTable *function_table; - zend_string *name; - - if (f->common.type != ZEND_USER_FUNCTION || - (f->op_array.refcount && *(f->op_array.refcount) < 2) || - !f->common.scope || - !f->common.scope->trait_aliases) { - return f->common.function_name; - } - - function_table = &ce->function_table; - ZEND_HASH_FOREACH_STR_KEY_PTR(function_table, name, func) { - if (func == f) { - if (!name) { - return f->common.function_name; - } - if (ZSTR_LEN(name) == ZSTR_LEN(f->common.function_name) && - !strncasecmp(ZSTR_VAL(name), ZSTR_VAL(f->common.function_name), ZSTR_LEN(f->common.function_name))) { - return f->common.function_name; - } - return zend_find_alias_name(f->common.scope, name); - } - } ZEND_HASH_FOREACH_END(); - return f->common.function_name; -} -/* }}} */ - ZEND_API ZEND_COLD const char *zend_get_object_type(const zend_class_entry *ce) /* {{{ */ { if(ce->ce_flags & ZEND_ACC_TRAIT) { |