Bug #48487 [Com]: fetch_object calls __set before constructor

From: Date: Thu, 01 Oct 2015 13:33:47 +0000
Subject: Bug #48487 [Com]: fetch_object calls __set before constructor
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196327@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48487&edit=1 ID: 48487 Comment by: grell at werk4 dot net Reported by: joel at purerave dot com Summary: fetch_object calls __set before constructor Status: Closed Type: Bug Package: MySQLi related Operating System: win2k sp4 PHP Version: 5.2.9 Block user comment: N Private report: N New Comment: ircmaxwell@php.net: Are you sure that this has never been released? In PHP 5.2.17 I see this exact behaviour. Testcase: <?php class TestClass { public function __construct() { echo 'construct'."\n"; } public function __set($key, $value) { echo 'set "'.$key.'" to "'.$value . '"' ."\n"; } } $db = new mysqli(); $db->query('SELECT "PHP" as name')->fetch_object('TestClass'); Expected output (as documented): set "name" to "PHP" construct Actual output: construct set "name" to "PHP" Previous Comments: ------------------------------------------------------------------------ [2014-04-28 14:51:31] ircmaxell@php.net Note that this is NOT fixed in any release. The change was reverted. Just leaving this note here so that anyone who stumbles on it in the future will not go chasing their tails. ------------------------------------------------------------------------ [2010-05-12 09:51:42] vadimx at gmail dot com In mysql_fetch_object the same bug. ------------------------------------------------------------------------ [2010-01-04 10:31:36] uw@php.net This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Fixed with http://news.php.net/php.cvs/61460 ------------------------------------------------------------------------ [2009-11-06 16:29:19] caferrari at gmail dot com Help!.. i am having this issue with php 5.2.10 on Ubuntu 9.10 and Debian 5... and its evil!... my solution: class Exemplo { public function __construct($id=0, $nome='', $sigla=''){ if (isset($this->id)) return; //Ugly solution!!! help! $this->id = $id; $this->nome = $nome; $this->sigla = $sigla; } } ------------------------------------------------------------------------ [2009-08-25 17:14:42] joel at purerave dot com No response yet? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=48487 -- Edit this bug report at https://bugs.php.net/bug.php?id=48487&edit=1

« previous php.bugs (#196327) next »