From: [email protected]
Operating system: Linux x86_64
PHP version: 5.3.0
PHP Bug Type: Scripting Engine problem
Bug description: call_user_func_array when calling a parent constructor not
from a user class
Description:
------------
When using:
call_user_func_array(array('parent', '__construct'), $var);
This works if the parent is a user-defined class, but not if it's an
extension-provided class (the extended constructor gets called twice).
This is not easy to explain, see attached reproduce code for more
details.
My initial code was (in a class extending mysqli):
private function __construct($params) {
call_user_func_array(array('parent', '__construct'),
$params);
$this->set_charset('utf8');
}
Using this instead awfully fixes the problem:
parent::__construct($params[0], $params[1], $params[2], $params[3]);
Note that this wasn't possible in PHP 5.2.x
Warning: call_user_func_array(): First argument is expected to be a valid
callback, 'parent::__construct' was given in foo.php on line 5
Reproduce code:
---------------
<?php
class B extends mysqli {
public function __construct($var) {
echo "here\n";
call_user_func_array(array('parent', '__construct'), $var);
}
}
$x = new B(array('localhost', 'root'));
Expected result:
----------------
here
Actual result:
--------------
here
here
Warning: call_user_func_array() expects parameter 2 to be array, string
given in foo.php on line 6
--
Edit bug report at http://bugs.php.net/?id=49203&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49203&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49203&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49203&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49203&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49203&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49203&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49203&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49203&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49203&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49203&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49203&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49203&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49203&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49203&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49203&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49203&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49203&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49203&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49203&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49203&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49203&r=mysqlcfg