Re: [Zend Engine 2] "parent" and deep "require"s

From: Date: Sat, 22 Jun 2002 20:07:29 +0000
Subject: Re: [Zend Engine 2] "parent" and deep "require"s
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-85497@lists.php.net to get a copy of this message
On Tue, 2002-06-11 at 00:04, Timm Friebe wrote: > ZE2 has a bug... Well, replying to myself:-) I took some time to have a look at where the bugs occur (see my original email to engine2@lists.zend.com, sent 11 Jun 2002 00:04:09 +0200) and think I got rid of them. > concerning the keyword "parent" and the way it behaves > erroneously in a situation like this: [...Source...] > thekid@friebes:~/devel/php-4.3.0-dev-zend2-alpha1 > ./php -q > test.ze2.php > int(2039) > string(9) "2.0.0-dev" > string(9) "4.3.0-dev" > <br /> > <b>Warning</b>: Missing argument 1 for __construct() > in > <b>/usr/home/thekid/devel/php-4.3.0-dev-zend2-alpha1/test.ze2.php</b> on > line <b>12</b><br /> > NULL > ===> Result: object(ioexception)(1) { > ["message"]=> > NULL > } The problem was the usage of the keyword "parent" and extending classes while not overwriting - say - the constructor (or any other function) - which then gets called for each inheritance. The problem had been fixed in Zend Engine 1 in Version 1.200 - but since now scopes have been introduced and everything works quite different, CG(active_ce_parent_class_name) of course will not do. http://cvs.php.net/diff.php/Zend/zend_compile.c?r1=1.199&r2=1.200&ty=u Attached is a patch to zend_execute.c which does the job. [...Source...] > Moving the contents of C.class.php into test-2.ze2.php will work: [...whereas if require()'d, it won't...] > I believe this is exactly the same as described in > http://bugs.php.net/bug.php?id=12313 - maybe the patches made > to ZE1 > then never made it to the ZE2 branch? Well, sort of:-) The problem was with runtime inheritance which is performed when classes extend classes in require()'d files, realized in do_inherit_parent_constructor(zend_class_entry *ce) - searching for the constructor by the name of the class only and not for __construct. The hashtable lookups can be replaced by simply checking on and using the much neater "constructor" field in zend_class_entry, I guess. Last but not least, the runtime inheritance of the destructor was completely forgotten, the attached patch to zend_compile.c solves both issues. Hope it helps & keep up the good work:-) -- Timm Friebe

Attachment: [text/x-c] diff_zend_compile.c
Attachment: [text/x-c] diff_zend_execute.c
Attachment: [application/x-php] test-1.ze2.php
Attachment: [application/x-php] test-2.ze2.php
« previous php.dev (#85497) next »