Issue Bug Closed

#57957TYPO3\CMS\Dbal\DatabasDatabaseConnection::sql_fetch_assoc() might return null

Tim mie 04/15/14, 18:40 updated 10/02/18, 11:58

Description

I found a little bug while using DBAL.

A little background,
In the default situation, TYPO3\CMS\Core\Database\DatabaseConnection::sql_fetch_assoc() returns FALSE if the end of a resultset is reached

When using DBAL, TYPO3\CMS\Dbal\Database\DatabaseConnection::sql_fetch_assoc() returns NULL if the end of a resultset is reached (using native mysqli driver).

In the class TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController (Typo3 6.2.0 LTS) at line 4777 it’s expected that sql_fetch_assoc() returns FALSE if the end is reached. When using DBAL this results in an infinite loop.

while (FALSE !== ($row = $GLOBALS[‘TYPO3_DB’]->sql_fetch_assoc($result))) {

Suggested solution is to add a check to TYPO3\CMS\Dbal\Database\DatabaseConnection::sql_fetch_assoc() at the end of a function to set the return value to FALSE if $output === null. The same is done in it’s parent “Needed for compatibility”

Reviews 2