#44425 [Opn->Csd]: Extending PDO/MySQL class with a __call() function doesn't work
| From: | johannes@php.net | Date: | Tue, 16 Sep 2008 23:37:51 +0000 |
| Subject: | #44425 [Opn->Csd]: Extending PDO/MySQL class with a __call() function doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129041@lists.php.net to get a copy of this message | ||
ID: 44425
Updated by: johannes@php.net
Reported By: phpbugs at wayoverthere dot com
-Status: Open
+Status: Closed
Bug Type: PDO related
Operating System: Linux/Windows
PHP Version: 5.2CVS-2008-03-13 (snap)
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-03-29 16:45:32] phpbugs at wayoverthere dot com
I have compiled directly from a CVS checkout (PHP_5_3) on openSuse
10.2, and I still see this problem. Is there anything I can do to
convince someone that this bug actually exists? I don't understand
how I'm the only one who can reproduce it, when I can reproduce it
anywhere I test it - even using the precompiled Windows snapshots.
I followed the instructions on compiling from CVS (meaning compiling
all the specific version requirements of autoconf, etc. and running
buildconf), and used these configure options:
./configure --prefix=/home/shared/php5cvs/ --with-zlib
--with-mysql=shared --enable-pdo=shared --with-pdo-mysql=shared
--with-pdo-sqlite=shared --with-sqlite=shared
My php.ini:
extension=pdo.so
extension=pdo_mysql.so
extension=pdo_sqlite.so
Running this test script:
<?php
class test extends PDO {
function __call($name, array $args) {
echo "Called $name in ".__CLASS__.'<br>';
}
function foo() {
echo "Called foo in ".__CLASS__.'<br>';
}
}
$sqlite = new test('sqlite::memory:');
$sqlite->foo();
$sqlite->bar();
$mysql = new test('mysql:dbname=test;host=localhost','root','');
$mysql->foo();
$mysql->bar();
?>
Gives:
Called foo in test<br>Called bar in test<br>Called foo in test<br>
Fatal error: Call to undefined method test::bar()
in /home/shared/php5cvs/test.php on line 17
If necessary, I might be able to provide ssh access to one of the
boxes I'm seeing this on.
------------------------------------------------------------------------
[2008-03-15 19:34:40] phpbugs at wayoverthere dot com
Can someone confirm/deny this bug using the Windows binary version as
I did? At least that way there's no compiling issues to complicate
things.
Also, I poked around cvs.php.net and found what I think is the fix
for #43663:
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.82.2.31.2.17.2.2&r2=1.82.2.31.2.17.2.3
I checked my local 5.3 snapshot and it does have those added lines.
------------------------------------------------------------------------
[2008-03-14 06:07:22] crrodriguez at suse dot de
Works for me as well, with current 5_3 CVS
------------------------------------------------------------------------
[2008-03-13 22:25:06] phpbugs at wayoverthere dot com
I'm still seeing the problem. I have recompiled PHP
(php5.3-200803131930) on several different boxes - all Linux, but
different distros (Ubuntu 7.10, openSuse 10.2, and a very old Gentoo
box). On a hunch, I uninstalled the system PHP, thinking the custom
PHP was using the system .so's. Same thing.
I even tried installing PHP on a Win2k box using the snapshot
http://snaps.php.net/win32/php5.3-win32-200803132030.zip.
I used the
recommended php.ini file as a base config file, but enabled
php_pdo.dll, php_pdo_mysql.dll, and php_pdo_sqlite.dll extensions.
Then I created test.php and put this in it:
<?php
class test extends PDO {
function __call($name, array $args) {
echo "Called $name in ".__CLASS__.'<br>';
}
function foo() {
echo "Called foo in ".__CLASS__.'<br>';
}
}
$sqlite = new test('sqlite::memory:');
$sqlite->foo();
$sqlite->bar();
$mysql = new test('mysql:dbname=foo;host=10.1.1.142','foo','bar');
$mysql->foo();
$mysql->bar();
?>
Running "php test.php" gives:
Called foo in test<br>Called bar in test<br>Called foo in
test<br>Fatal error: Call to undefined method test::bar() in C:
\php5\test.php on line 17
------------------------------------------------------------------------
[2008-03-13 16:10:44] iliaa@php.net
Works fine in snapshot and PHP 5.3
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/44425
--
Edit this bug report at http://bugs.php.net/?id=44425&edit=1