Skip to content

Commit 2c98da2

Browse files
committed
MFH Fix #44425 (Extending PDO/MySQL class with a __call() function doesn't work)
1 parent 4c32eb9 commit 2c98da2

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

ext/pdo/pdo_dbh.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,9 +1293,6 @@ static union _zend_function *dbh_method_get(
12931293

12941294
if (zend_hash_find(dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_DBH],
12951295
lc_method_name, method_len+1, (void**)&fbc) == FAILURE) {
1296-
if (std_object_handlers.get_method) {
1297-
fbc = std_object_handlers.get_method(object_pp, lc_method_name, method_len TSRMLS_CC);
1298-
}
12991296

13001297
if (!fbc) {
13011298
fbc = NULL;
@@ -1307,6 +1304,12 @@ static union _zend_function *dbh_method_get(
13071304
}
13081305

13091306
out:
1307+
if (!fbc) {
1308+
if (std_object_handlers.get_method) {
1309+
fbc = std_object_handlers.get_method(object_pp, lc_method_name, method_len TSRMLS_CC);
1310+
}
1311+
}
1312+
13101313
efree(lc_method_name);
13111314
return fbc;
13121315
}

ext/pdo_mysql/tests/pdo_mysql_subclass.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if (version_compare(PHP_VERSION, '5.0.0', '<'))
3636
}
3737

3838
public function __call($method, $args) {
39-
print "__call()";
39+
print "__call(".var_export($method,true).", ".var_export($args, true).")\n";
4040
// $this->protocol();
4141
}
4242

@@ -74,8 +74,6 @@ if (version_compare(PHP_VERSION, '5.0.0', '<'))
7474
$db->exec('DROP TABLE IF EXISTS test');
7575
print "done!\n";
7676
?>
77-
--XFAIL--
78-
PDO doesn't like __call()
7977
--EXPECTF--
8078
__construct('%s', '%s', '%s')
8179
exec('DROP TABLE IF EXISTS test')

0 commit comments

Comments
 (0)