From:
Operating system: Linux
PHP version: 5.3.8
Package: Arrays related
Bug Type: Bug
Bug description:ReflectionMethod::InvokeArgs not work normally in function
Description:
------------
If I try to use ReflectionMethod::InvokeArgs after using function
array_unshift inside of user function, this return me this:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a
reference, value given in /www/transaction_test.php on line 132
Fatal error: Uncaught exception 'ReflectionException' with message
'Invocation of method mysqli_stmt::bind_param() failed' in
/www/transaction_test.php:132 Stack trace: #0
/www/transaction_test.php(132):
ReflectionMethod->invokeArgs(Object(mysqli_stmt), Array) #1
/www/transaction_test.php(146): test_case_function('INSERT INTO `te...',
Array, 'ss') #2 {main} thrown in /www/transaction_test.php on line 132
If I try run it out of user function. Everything is OK.
Test script:
---------------
function test_case_function ($sql,$variables,$vars) {
$mysqli = new mysqli(db_server, db_user_name, db_user_passwd, db_name);
$mysqli->query("SET NAMES 'utf8'") or die ('Could not set Charset');
$mysqli->autocommit(FALSE);
array_unshift($variables,$vars);
if ($stm=$mysqli->prepare($sql)) {
$method= new ReflectionMethod('mysqli_stmt','bind_param');
$method->invokeArgs($stm,$variables);
}
$stm->execute();
printf("%d Row inserted\n", $stm->affected_rows);
$mysqli->commit();
$stm->close();
$mysqli->close();
}
$sql = "INSERT INTO `test_table` (`time`,`one`,`two`) VALUES
(NOW(),?,?);";
$vars = 'ss';
$variables = array ("one62","two62");
test_case_function($sql,$variables,$vars);
Expected result:
----------------
Script print "1 Row inserted "
Actual result:
--------------
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a
reference, value given in /www/transaction_test.php on line 132
Fatal error: Uncaught exception 'ReflectionException' with message
'Invocation of method mysqli_stmt::bind_param() failed' in
/www/transaction_test.php:132 Stack trace: #0
/www/transaction_test.php(132):
ReflectionMethod->invokeArgs(Object(mysqli_stmt), Array) #1
/www/transaction_test.php(146): test_case_function('INSERT INTO `te...',
Array, 'ss') #2 {main} thrown in /www/transaction_test.php on line 132
--
Edit bug report at https://bugs.php.net/bug.php?id=60601&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60601&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60601&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60601&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60601&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60601&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60601&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60601&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60601&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60601&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60601&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60601&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60601&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60601&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60601&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60601&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60601&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60601&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60601&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60601&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60601&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60601&r=mysqlcfg