Can not properly subclass mysqli_stmt
| Bug #34785 | Can not properly subclass mysqli_stmt | ||||
|---|---|---|---|---|---|
| Submitted: | 2005-10-08 01:11 UTC | Modified: | 2005-10-08 17:09 UTC | ||
| From: | squasar at eternalviper dot net | Assigned: | georg (profile) | ||
| Status: | Closed | Package: | MySQLi related | ||
| PHP Version: | 5CVS-2005-10-08 (cvs) | OS: | * | ||
| Private report: | No | CVE-ID: | None | ||
[2005-10-08 01:11 UTC] squasar at eternalviper dot net
Description:
------------
If mysqli_stmt is subclassed (only makes sense in PHP 5.1.0 or
above), calling parent::__construct() results in "Fatal error:
Can not call constructor".
Fix:
Index: ext/mysqli/mysqli_fe.c
==============================================================
=====
RCS file: /repository/php-src/ext/mysqli/mysqli_fe.c,v
retrieving revision 1.49
diff -r1.49 mysqli_fe.c
285a286
> PHP_FALIAS(mysqli_stmt,mysqli_stmt_construct,NULL)
Reproduce code:
---------------
<?php
class my_stmt extends mysqli_stmt {
public function __construct( $link, $query ) {
parent::__construct( $link, $query );
}
}
$conn = new mysqli;
$stmt = new my_stmt( $conn, "SELECT 1 FROM DUAL" );
var_dump( $stmt );
?>
Expected result:
----------------
object(my_stmt)#2 (0) {
}
Actual result:
--------------
Fatal error: Can not call constructor in - on line 4
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2005-10-08 01:13 UTC] squasar at eternalviper dot net
Here's the udiff for the fix: Index: ext/mysqli/mysqli_fe.c ============================================================ ======= RCS file: /repository/php-src/ext/mysqli/mysqli_fe.c,v retrieving revision 1.49 diff -u -r1.49 mysqli_fe.c --- ext/mysqli/mysqli_fe.c 3 Aug 2005 14:07:30 -0000 1.49 +++ ext/mysqli/mysqli_fe.c 7 Oct 2005 23:12:05 -0000 @@ -283,6 +283,7 @@ PHP_FALIAS(reset,mysqli_stmt_reset,NULL) PHP_FALIAS(prepare,mysqli_stmt_prepare, NULL) PHP_FALIAS (store_result,mysqli_stmt_store_result,NULL) + PHP_FALIAS(mysqli_stmt,mysqli_stmt_construct,NULL) {NULL, NULL, NULL} }; /* }}} */[2005-10-08 01:38 UTC] sniper@php.net
[2005-10-08 17:09 UTC] georg@php.net