php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46542 Extending PDO class with a __call() function doesn't work as expected
Submitted: 2008-11-11 10:23 UTC Modified: 2013-10-26 09:38 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: myardbenoit at gmail dot com Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.6 OS: GNU/Linux
Private report: No CVE-ID: None
 [2008-11-11 10:23 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-11 17:40 UTC] 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.
 [2009-02-17 14:45 UTC] johannes@php.net
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.
 [2011-11-16 13:17 UTC] felipe@php.net
-Package: PDO related +Package: Documentation problem
 [2013-10-26 09:37 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331999
Log: #46542 PDO __call behaviour &lt;5.3
 [2013-10-26 09:38 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-10-26 09:38 UTC] krakjoe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC