ID:               43831
 Comment by:       dennis at born05 dot nl
 Reported By:      mjs at beebo dot org
 Status:           Verified
 Bug Type:         PDO related
 Operating System: OS X/Linux
 PHP Version:      5.2CVS, 5.3CVS, 6CVS
 Assigned To:      wez
 New Comment:

A simpler case might be:

class MyPDO extends PDO {}

$bar = new PDO("sqlite::memory:", null, null, 
array(PDO::ATTR_PERSISTENT => true));
$baz = new MyPDO("sqlite::memory:", null, null, 
array(PDO::ATTR_PERSISTENT => true));

var_dump ($bar);
var_dump ($baz);

It looks like it internally caches the object, not just the 
connection..

Tested on Fedora Core 6, latest snaps of both 5.2 and 5.3 branch.


Previous Comments:
------------------------------------------------------------------------

[2008-10-24 21:13:03] fel...@php.net

/home/felipe/dev/php5/ext/pdo/pdo_dbh.c(1516) :  Freeing 0x088CEA34 (44
bytes), script=../bug.php
[Fri Oct 24 18:55:13 2008]  Script:  '../bug.php'
/home/felipe/dev/php5/ext/pdo/pdo_dbh.c(1517) :  Freeing 0x088D7844 (32
bytes), script=../bug.php
/home/felipe/dev/php5/Zend/zend_alloc.c(2391) : Actual location
(location was relayed)
=== Total 2 memory leaks detected ===


------------------------------------------------------------------------

[2008-10-24 21:12:47] fel...@php.net

/home/felipe/dev/php5/ext/pdo/pdo_dbh.c(1516) :  Freeing 0x088CEA34 (44
bytes), script=../bug.php
[Fri Oct 24 18:55:13 2008]  Script:  '../bug.php'
/home/felipe/dev/php5/ext/pdo/pdo_dbh.c(1517) :  Freeing 0x088D7844 (32
bytes), script=../bug.php
/home/felipe/dev/php5/Zend/zend_alloc.c(2391) : Actual location
(location was relayed)
=== Total 2 memory leaks detected ===


------------------------------------------------------------------------

[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

Reply via email to