Bug #50378

sql_free_result does not work with all parameters as specified

Added by Robert Vock about 9 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2013-07-24
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.1
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

The method "sql_free_result" of the DatabaseConnection class throws a fatal error when called with the (boolean) result of exec_INSERTquery.

The direct mail extension uses the following code:

$res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_dmail_maillog', $insertFields);
$GLOBALS['TYPO3_DB']->sql_free_result($res);

This results in a fatal error because $res is boolean true and sql_free_result asumes it is an object.

The method description of sql_free_result says that it is ok, to call the method with a boolean:

 * @param boolean|\mysqli_result|object $res MySQLi result object / DBAL object

The fix would be to check if the parameter is an object before calling the free-method.
Another "fix" would be to change the method description, but that would leave bugs in extensions which relied on the ability to call sql_free_result with boolean results.

Note: In TYPO3 4.7 sql_free_result would just call mysql_free_result, which would not throw a fatal error, when called with a boolean parameter, but just return false.

Also available in: Atom PDF