#43717 [NEW]: __construct() could be called after calling __set() by PDO

From: Date: Mon, 31 Dec 2007 09:22:22 +0000
Subject: #43717 [NEW]: __construct() could be called after calling __set() by PDO
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120955@lists.php.net to get a copy of this message
From: tohru at nakarika dot com Operating system: FreeBSD 6.1-RELEASE-p10 PHP version: 5.2.5 PHP Bug Type: PDO related Bug description: __construct() could be called after calling __set() by PDO Description: ------------ when you call PDOStatement::fetch() with the fetch mode PDO::FETCH_CLASS PDO will create FooClass' instance. And in the creation process PDO (or script engine?) calls __set() method before calling FooClass' __construct(). Reproduce code: --------------- class FooClass { public function __construct($param) { echo "FooClass::constructor\n"; } protected function &__set($name, $value) { echo "FooClass::__set()\n"; } } $pdo = new PDO($dsn, ...); $stmt = $pdo->prepare('SELECT * FROM ...'); $stmt->setFetchMode(PDO::FETCH_CLASS, FooClass, array('bar')); $fooInst = $stmt->fetch(); Expected result: ---------------- The script should output strings in the following order: 1. FooClass::constructor 2. FooClass::__set() Actual result: -------------- 1. FooClass::__set() 2. FooClass::constructor -- Edit bug report at http://bugs.php.net/?id=43717&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43717&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43717&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43717&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43717&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43717&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43717&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43717&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43717&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43717&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43717&r=support Expected behavior: http://bugs.php.net/fix.php?id=43717&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43717&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43717&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43717&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43717&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43717&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43717&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43717&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43717&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43717&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43717&r=mysqlcfg

« previous php.bugs (#120955) next »