Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:2178 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58683 invoked from network); 5 Jun 2003 08:57:04 -0000 Received: from unknown (HELO secure.thebrainroom.com) (213.239.42.171) by pb1.pair.com with SMTP; 5 Jun 2003 08:57:04 -0000 Received: from zaneeb.brainnet.i (IDENT:root@brain.dial.nildram.co.uk [195.149.29.154]) by secure.thebrainroom.com (8.9.3/8.9.3) with ESMTP id JAA23342; Thu, 5 Jun 2003 09:56:52 +0100 Received: from zaneeb.brainnet.i (IDENT:wez@zaneeb.brainnet.i [127.0.0.1]) by zaneeb.brainnet.i (8.11.6/8.11.6) with ESMTP id h558uq827328; Thu, 5 Jun 2003 09:56:52 +0100 Date: Thu, 5 Jun 2003 09:56:52 +0100 (BST) X-X-Sender: wez@zaneeb.brainnet.i To: internals@lists.php.net cc: zeev@zend.com Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: define()d constants in constant arrays break on inheritance From: wez@thebrainroom.com (Wez Furlong) This bug has been around a long time; I actually thought that define()s wouldn't work at all in scalar initializers until today :) 'a'); } class Bar extends Foo {} var_dump(get_class_vars('Foo')); // bar => array(200 => 'a') var_dump(get_class_vars('Bar')); // bar => array('A' => 'a') ?> If you comment out the first get_class_vars line, then the output for Bar is correct (200 => 'a'). I tracked down the problem to zval_update_constant(); when it walks the array it turns of the IS_CONSTANT_INDEX bit on the original zval. So, when it is called subsequently it doesn't know that it should lookup the constant name. The patch at http://www.php.net/~wez/define_inherit.diff fixes this problem by making a copy of the element and clearing the bit in the copy, and removing the reference to the original element from the array. --Wez.