Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44346 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50996 invoked from network); 17 Jun 2009 15:44:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2009 15:44:04 -0000 Authentication-Results: pb1.pair.com header.from=scott@macvicar.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=scott@macvicar.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain macvicar.net from 97.107.131.220 cause and error) X-PHP-List-Original-Sender: scott@macvicar.net X-Host-Fingerprint: 97.107.131.220 whisky.macvicar.net Linux 2.6 Received: from [97.107.131.220] ([97.107.131.220:60691] helo=whisky.macvicar.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/64-51188-14F093A4 for ; Wed, 17 Jun 2009 11:44:02 -0400 Received: from balrog.jelsoft.local (office.vbulletin.com [217.155.246.60]) by whisky.macvicar.net (Postfix) with ESMTP id 48DC346957; Wed, 17 Jun 2009 11:43:54 -0400 (EDT) Message-ID: To: internals Mailing List Content-Type: multipart/mixed; boundary=Apple-Mail-6-658260525 Mime-Version: 1.0 (Apple Message framework v935.3) Date: Wed, 17 Jun 2009 16:43:52 +0100 Cc: dmitry@php.net, tony2001@php.net X-Mailer: Apple Mail (2.935.3) Subject: PHP Bug 48215 From: scott@macvicar.net (Scott MacVicar) --Apple-Mail-6-658260525 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hey, Bug 48215 was a BC break from the previous 5.2 behaviour, it stemmed from a change for bug #39127. class a { function a($arg='') { echo $arg; } } class b extends a {} $b = new b; $b->b('foo'); $b->__construct('foo'); This prints out an error in 5.3 which is fine, the unexpected change was that if a __construct() method was actually defined as well as a method that matched the class name it would alias the parent method to the constructor. The test is attached in the patch. Just sending off to internals first since we're so late in the RC stage. Scott --Apple-Mail-6-658260525 Content-Disposition: attachment; filename=bug48215.patch.txt Content-Type: text/plain; x-unix-mode=0644; name="bug48215.patch.txt" Content-Transfer-Encoding: 7bit Index: tests/bug48215.phpt =================================================================== RCS file: tests/bug48215.phpt diff -N tests/bug48215.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/bug48215.phpt 17 Jun 2009 15:37:26 -0000 @@ -0,0 +1,38 @@ +--TEST-- +Bug #48215 - parent::method() calls __construct +--FILE-- +A(); +?> +===DONE=== +--EXPECTF-- + +Strict Standards: Redefining already defined constructor for class A in %s on line %d +B::__construct +A::__construct +B::A +A::A +===DONE=== Index: zend_object_handlers.c =================================================================== RCS file: /repository/ZendEngine2/zend_object_handlers.c,v retrieving revision 1.135.2.6.2.22.2.29 diff -u -r1.135.2.6.2.22.2.29 zend_object_handlers.c --- zend_object_handlers.c 12 Jun 2009 21:36:53 -0000 1.135.2.6.2.22.2.29 +++ zend_object_handlers.c 17 Jun 2009 15:37:26 -0000 @@ -28,6 +28,7 @@ #include "zend_object_handlers.h" #include "zend_interfaces.h" #include "zend_closures.h" +#include "zend_compile.h" #define DEBUG_OBJECT_HANDLERS 0 @@ -941,7 +942,8 @@ if (function_name_strlen == ce->name_length && ce->constructor) { lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length); - if (!memcmp(lc_class_name, function_name_strval, function_name_strlen)) { + /* Only change the method to the constructor if a __construct() method doesn't exist */ + if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) { fbc = ce->constructor; } efree(lc_class_name); --Apple-Mail-6-658260525 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-6-658260525--