Bug #65941
closedTYPO3\CMS\Core\Database\PreparedStatement::execute() calls mysqli_stmt::bind_param() with zero parameters to bind
100%
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
Updated by Gerrit Code Review over 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/38097
Updated by Mathias Schreiber over 9 years ago
- Sprint Focus set to On Location Sprint
Updated by Gerrit Code Review over 9 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/38386
Updated by Andreas Fernandez over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset da7f1c0fa66d76d11d81be91315d2ed431a1dd89.
Updated by Anja Leichsenring almost 9 years ago
- Sprint Focus deleted (
On Location Sprint)