Actions
Bug #65941
closedTYPO3\CMS\Core\Database\PreparedStatement::execute() calls mysqli_stmt::bind_param() with zero parameters to bind
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2015-03-23
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.5
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:
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.
Files
Actions