com php-src: 63911: Compare opcodes of the op_array to de termine different functions: NEWS Zend/tests/traits/b ug63911.phpt Zend/zend_inheritance.c

From: Date: Wed, 22 Nov 2017 05:35:24 +0000
Subject: com php-src: 63911: Compare opcodes of the op_array to de termine different functions: NEWS Zend/tests/traits/b ug63911.phpt Zend/zend_inheritance.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100343@lists.php.net to get a copy of this message
Commit: 179ed6e43d9703fe6bdaa286aec79f7e131a8ab0 Author: Pedro Magalhães <mail@pmmaga.net> Sat, 30 Sep 2017 21:24:38 +0100 Committer: krakjoe <krakjoe@php.net> Wed, 22 Nov 2017 05:35:24 +0000 Parents: f3545165b2417b5e54b8da888d39f35c5793e684 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=179ed6e43d9703fe6bdaa286aec79f7e131a8ab0 Log: 63911: Compare opcodes of the op_array to determine different functions Changed paths: M NEWS A Zend/tests/traits/bug63911.phpt M Zend/zend_inheritance.c Diff: diff --git a/NEWS b/NEWS index 152e3de..a86a3bf 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ PHP NEWS files). (petk) . Fixed bug #74922 (Composed class has fatal error with duplicate, equal const properties). (pmmaga) + . Fixed bug #63911 (identical trait methods raise errors during composition). + (pmmaga) - BCMath: . Fixed bug #66364 (BCMath bcmul ignores scale parameter). (cmb) diff --git a/Zend/tests/traits/bug63911.phpt b/Zend/tests/traits/bug63911.phpt new file mode 100644 index 0000000..72892cd --- /dev/null +++ b/Zend/tests/traits/bug63911.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #63911 (Ignore conflicting trait methods originationg from identical sub traits) +--FILE-- +<?php +trait A +{ + public function a(){ + echo 'Done'; + } +} +trait B +{ + use A; +} +trait C +{ + use A; +} +class D +{ + use B, C; +} + +(new D)->a(); +--EXPECT-- +Done diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index c7391f9..7f253d9 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1165,6 +1165,11 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s zend_function *new_fn; if ((existing_fn = zend_hash_find_ptr(&ce->function_table, key)) != NULL) { + /* if it is the same function regardless of where it is coming from, there is no conflict and we do not need to add it again */ + if (existing_fn->op_array.opcodes == fn->op_array.opcodes) { + return; + } + if (existing_fn->common.scope == ce) { /* members from the current class override trait methods */ /* use temporary *overriden HashTable to detect hidden conflict */

« previous php.cvs (#100343) next »