php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52617 call_user_func_array don't properly get parameters to a method
Submitted: 2010-08-16 11:24 UTC Modified: 2010-08-19 11:19 UTC
From: s dot cimini at email dot it Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.3.3 OS: Ubuntu Server 10.04 32 bit
Private report: No CVE-ID: None
 [2010-08-16 11:24 UTC] s dot cimini at email dot it
Description:
------------
The PHP version is 5.3.2 and not 5.3.3, but 5.3.2 is not present in the combo.

When i try do execute a script that with PHP 5.2.9 on a Windows pc works in a Ubuntu server 10.04 with PHP 5.3.2 don't work.

It appears that the second part of the function, the part relative to the parameters, don't get the parameters to the method of the first part.

Test script:
---------------
$db_user="root";
$db_password="password";
$db_host="localhost";
$mysqli = new mysqli($db_host, $db_user, $db_password, "database");
$query = "select id from table where name like ?";
$types="s";
$values[]="a%";
$stmt = $mysqli->prepare($query);
call_user_func_array(array($stmt, "bind_param"), array_merge(array($types),$values));
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
    echo($id."<br />");
}
$mysqli->close();


Expected result:
----------------
A list of ids.

Actual result:
--------------
Nothing and the excution don't give any errors

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-17 03:32 UTC] felipe@php.net
I cannot reproduce any problem using the follow sample code:
var_dump(call_user_func_array(array(new simplexmlelement('<a><b/></a>'), 'xpath'), array('//a')));
 [2010-08-17 17:27 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-08-17 17:27 UTC] johannes@php.net
The behavior of PHP 5.2 was wrong and got fixed. bind_param expects references, so you have to pass an array of referenced variables to the method. If you have full error reporting you should receive an error message about this.
 [2010-08-19 11:19 UTC] s dot cimini at email dot it
I've tried the code on Ubuntu Desktop 10.04 32bit, 10.04 64bit and Server 32bit, all this versions are using PHP 5.3.2. There is effectively an error, i haven't set the Display_error = On, now it's set to On.

This is the error: Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in /var/www/test.php on line 11 

I've tried also:

$val=array_merge(array($types),$values);
call_user_func_array(array($stmt, "bind_param"), $val);

and 

$val=array_merge(array($types),$values);
call_user_func_array(array($stmt, "bind_param"), &$val);

But the error is the same.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Aug 17 17:00:03 2025 UTC