Bug #18966
closedPHP Warning, if a sql error occurs - Bug in class t3lib_db function sql_fetch_assoc
0%
Description
mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /pfad/typo3/t3lib/class.t3lib_db.php on line 796
This error occurs because the SQL select has an error. But it would be better if such PHP Errors does not occurs all the time. Here the fix in the file /t3lib/class.t3lib_db.php on line 796
/**
* Returns an associative array that corresponds to the fetched row, or FALSE if there are no more rows.
* mysql_fetch_assoc() wrapper function
* Usage count/core: 307
*
* @param pointer MySQL result pointer (of SELECT query) / DBAL object
* @return array Associative array of result row.
*/
function sql_fetch_assoc($res) {
if($this->debug_check_recordset($res)){
return mysql_fetch_assoc($res);
} else {
return false;
}
}
instead of the original code:
---------------------------------------
/**
* Returns an associative array that corresponds to the fetched row, or FALSE if there are no more rows.
* mysql_fetch_assoc() wrapper function
* Usage count/core: 307
*
* @param pointer MySQL result pointer (of SELECT query) / DBAL object
* @return array Associative array of result row.
*/
function sql_fetch_assoc($res) {
$this->debug_check_recordset($res);
return mysql_fetch_assoc($res);
}
I think, when the check function debug_check_recordset is used, the return value should be interpreted.
(issue imported from #M8728)
Files