#43831 [Opn->Asn]: $this gets mangled when extending PDO with persistent connection

From: Date: Mon, 28 Jan 2008 23:39:19 +0000
Subject: #43831 [Opn->Asn]: $this gets mangled when extending PDO with persistent connection
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121644@lists.php.net to get a copy of this message
ID: 43831 Updated by: tony2001@php.net Reported By: mjs at beebo dot org -Status: Open +Status: Assigned Bug Type: PDO related Operating System: OS X/Linux PHP Version: 5.2.5 -Assigned To: +Assigned To: wez Previous Comments: ------------------------------------------------------------------------ [2008-01-13 20:55:43] mjs at beebo dot org Description: ------------ The class of $this changes after the instantiation of a class which extends PDO, and which specifies PDO::ATTR_PERSISTENT attribute. Reproduce code: --------------- class Foo extends PDO { function __construct($dsn) { parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true)); } } class Baz extends PDO { function __construct($dsn) { parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true)); } } class Bar extends Baz { function quux() { echo get_class($this), "\n"; $foo = new Foo("sqlite::memory:"); echo get_class($this), "\n"; } } $bar = new Bar("sqlite::memory:"); $bar->quux(); Expected result: ---------------- Bar Bar i.e. get_class($this) returns the same value each time Actual result: -------------- Bar Foo i.e. $this gets mangled ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43831&edit=1

« previous php.bugs (#121644) next »