From:
Operating system: *nix & Win
PHP version: 5.3.2
Package: PDO related
Bug Type: Bug
Bug description:Own PDOStatement implementation ignore __call()
Description:
------------
When using an own PDOStatement implementation, __call() is simply ignored
in it.
*Additionally* it may lead to segfaults if the Statement object is user
constructed.
The problem is in pdo_stmt.c _zend_function *dbstmt_method_get(){ :
if (zend_hash_find(&Z_OBJCE_P(object)->function_table, lc_method_name,
method_len+1, (void**)&fbc) == FAILURE) {
pdo_stmt_t *stmt = (pdo_stmt_t*)zend_object_store_get_object(object
TSRMLS_CC);
if (!stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) {
[...]
stmt is not initialized properly when it comes back from the object store.
I didn't search deeper from that point.
The bug has already been reported and marked as fixed (46396), but it
doesn't seem to have been fixed.
Test script:
---------------
<?php
class MyStatement extends PDOStatement
{
public function __call($meth, $args)
{
return "$meth called";
}
}
$p = new PDO('sqlite::memory:');
$p->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyStatement'));
$r = $p->query('SELECT 123');
echo $r->foo(); // (1)
$obj = new MyStatement;
echo $obj->foo(); // (2)
Expected result:
----------------
foo called (1)
foo called (2)
Actual result:
--------------
Fatal error: Call to undefined method MyStatement::foo() in XXXX (1)
Segmentation Fault (2)
--
Edit bug report at http://bugs.php.net/bug.php?id=52098&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52098&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52098&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52098&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52098&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52098&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52098&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52098&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52098&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52098&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52098&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52098&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52098&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52098&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52098&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52098&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52098&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52098&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52098&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52098&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52098&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52098&r=mysqlcfg