diff options
-rw-r--r-- | ext/pdo/pdo_stmt.c | 6 | ||||
-rw-r--r-- | ext/pdo/tests/bug_52098.phpt | 59 |
2 files changed, 64 insertions, 1 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 5427d7aa5b..da557b8597 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1240,7 +1240,6 @@ static int pdo_stmt_verify_mode(pdo_stmt_t *stmt, zend_long mode, int fetch_all) return 0; } /* fall through */ - default: if ((flags & PDO_FETCH_SERIALIZE) == PDO_FETCH_SERIALIZE) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO::FETCH_SERIALIZE can only be used together with PDO::FETCH_CLASS"); @@ -2218,6 +2217,7 @@ static union _zend_function *dbstmt_method_get(zend_object **object_pp, zend_str lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0); zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name)); + if ((fbc = zend_hash_find_ptr(&object->ce->function_table, lc_method_name)) == NULL) { pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); /* instance not created by PDO object */ @@ -2242,6 +2242,9 @@ static union _zend_function *dbstmt_method_get(zend_object **object_pp, zend_str out: zend_string_release(lc_method_name); + if (!fbc) { + fbc = std_object_handlers.get_method(object_pp, method_name, key); + } return fbc; } @@ -2622,6 +2625,7 @@ static union _zend_function *row_method_get( } zend_string_release(lc_method_name); + return fbc; } diff --git a/ext/pdo/tests/bug_52098.phpt b/ext/pdo/tests/bug_52098.phpt new file mode 100644 index 0000000000..c9d39af522 --- /dev/null +++ b/ext/pdo/tests/bug_52098.phpt @@ -0,0 +1,59 @@ +--TEST-- +PDO Common: Bug #52098 Own PDOStatement implementation ignore __call() +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded('pdo')) die('skip'); +$dir = getenv('REDIR_TEST_DIR'); +if (false == $dir) die('skip no driver'); +require_once $dir . 'pdo_test.inc'; +PDOTest::skip(); +?> +--FILE-- +<?php +if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); +require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; +$db = PDOTest::factory(); + +@$db->exec("DROP TABLE test"); +$db->exec("CREATE TABLE test (x int)"); +$db->exec("INSERT INTO test VALUES (1)"); + +class MyStatement extends PDOStatement +{ + public function __call($name, $arguments) + { + echo "Calling object method '$name'" . implode(', ', $arguments). "\n"; + } +} +/* +Test prepared statement with PDOStatement class. +*/ +$derived = $db->prepare('SELECT * FROM test', array(PDO::ATTR_STATEMENT_CLASS=>array('MyStatement'))); +$derived->execute(); +$derived->foo(); +$derived->fetchAll(); +$derived = null; + +/* +Test regular statement with PDOStatement class. +*/ +$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyStatement')); +$r = $db->query('SELECT * FROM test'); +echo $r->bar(); +$r->fetchAll(); +$r = null; + +/* +Test object instance of PDOStatement class. +*/ +$obj = new MyStatement; +echo $obj->lucky(); + +$db->exec("DROP TABLE test"); +?> +===DONE=== +--EXPECTF-- +Calling object method 'foo' +Calling object method 'bar' +Calling object method 'lucky' +===DONE===
\ No newline at end of file |