#46542 [Asn->Tbd]: Extending PDO class with a __call() function doesn't work as expected

From: Date: Tue, 17 Feb 2009 14:45:02 +0000
Subject: #46542 [Asn->Tbd]: Extending PDO class with a __call() function doesn't work as expected
References: 1  Groups: php.bugs php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1890@lists.php.net to get a copy of this message
 ID:               46542
 Updated by:       johannes@php.net
 Reported By:      myardbenoit at gmail dot com
-Status:           Assigned
+Status:           To be documented
 Bug Type:         PDO related
 Operating System: GNU/Linux
 PHP Version:      5.2.6
 Assigned To:      johannes
 New Comment:

This is fixed in HEAD and 5.3. Won't merge to 5.2 as this is a BC
break.

Documentation team: Please mention this in the docs, in PHP < 5.3 the
method name will be lower cased, in PHP >=5.3 the casing is kept and the
user has to lowercase himself if needed, as it is with all other
__call() cases.


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

[2008-11-11 17:40:39] johannes@php.net

Thanks for the report, I could verify it and have a fix quite ready ..
just testing it.

Yes, __call and PDO is a bit weird in some situations: in current PHP
versions there's a bug that a __call() method is not called if a driver
has no own methods (like PDO_mysql) but that bug is fixed in CVS for
some time.

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

[2008-11-11 10:23:16] myardbenoit at gmail dot com

Description:
------------
A user-defined class extending PDO will have troubles with __call():
the method name passed to __call() is always lowercase.

As far as I can tell, it only happens when extending PDO.

As a side-note, I have seen several issues with __call() and PDO.. is
there anything special about PDO which could explain that ?

Reproduce code:
---------------
class A extends PDO
{ function __call($m, $p) {print __CLASS__."::$m\n";} }

class B extends XSLTProcessor
{ function __call($m, $p) {print __CLASS__."::$m\n";} }

$a = new A('sqlite:dummy.db');

$a->truc();
$a->TRUC();

$b = new B();

$b->truc();
$b->TRUC();

Expected result:
----------------
A::truc
A::TRUC <-----------
B::truc
B::TRUC

Actual result:
--------------
A::truc
A::truc <-----------
B::truc
B::TRUC


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


-- 
Edit this bug report at http://bugs.php.net/?id=46542&edit=1



Thread (1 message)

  • johannes@php.net
  • Unknown Message
    • johannes@php.net
« previous php.doc.bugs (#1890) next »