#65941TYPO3\CMS\Core\Database\PreparedStatement::execute() calls mysqli_stmt::bind_param() with zero parameters to bind
Description
When querying a PreparedStatement without any arguments (implicitely or explicitely), such as by
$stmt = $GLOBALS['TYPO3_DB']->prepare_SELECTquery('myColumn', 'myTable', ''); // select, from, where
$stmt->execute(array());
the following PHP warning will be logged:
PHP Warning: Wrong parameter count for mysqli_stmt::bind_param() in .../typo3_src-6.2.11/typo3/sysext/core/Classes/Database/PreparedStatement.php on line 354
The offending lines are:
346 // ->bind_param requires second up to last arguments as references
347 $bindParamArguments = array();
348 $bindParamArguments[] = $combinedTypes;
349 $numberOfExtraParamArguments = count($values);
350 for ($i = 0; $i < $numberOfExtraParamArguments; $i++) {
351 $bindParamArguments[] = &$values[$i];
352 }
353
354 call_user_func_array(array($this->statement, 'bind_param'), $bindParamArguments);
$combinedTypes is a string assembled earlier in execute() to contain all parameter’s data types. If no parameters have been passed, $combinedTypes is an empty string and (on line 354) $bindParamArguments therefore reads:
Array
(
[0] =>
)
This appears to get mapped to an unnecessary call of PHP’s mysqli_stmt::bind_param('') which should causes the logged warning.
A patch which encloses lines 350-354 in a check for $numberOfExtraParamArguments > 0 has been attached to this issue.