Bug #50378
closedsql_free_result does not work with all parameters as specified
100%
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.
Updated by Ernesto Baschny over 11 years ago
- Project changed from 329 to TYPO3 Core
Updated by Ernesto Baschny over 11 years ago
- Category set to Database API (Doctrine DBAL)
- Status changed from New to Needs Feedback
This is not a DBAL issue but a general Core issue. So I moved it to the right tracker.
I wonder how this works in 4.7, because first thing sql_free_result does is a:
if ($this->debug_check_recordset($res)) {
and this should then choke (logging errors to sys_log etc) when called without a resource.
What Fatal error do you get?
Updated by Robert Vock over 11 years ago
debug_check_recordset returns true, if $res is !== FALSE and does not log anything to sys_log
So if $res is true, debug_check_recordset also returns true. (exec_INSERTquery returns true, if the insert succeeded)
The fatal error is:
Fatal error: Call to a member function free() on a non-object in .../typo3/sysext/core/Classes/Database/DatabaseConnection.php on line 1070
Updated by Gerrit Code Review over 11 years ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22594
Updated by Markus Klein over 10 years ago
- Is Regression set to No
I'd say that is actually NOT a core bug at all.
Why calling free() at all after an insert??
No resources are allocated for an insert statement.
It is ok to add a check in Core to assure that we ignore boolean values.
Updated by Gerrit Code Review over 10 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22594
Updated by Gerrit Code Review over 10 years ago
Patch set 1 for branch TYPO3_6-1 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/29413
Updated by Wouter Wolters over 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset b93d9b456eea5e48ec9426931e0f9e0d3acc8211.