Project

General

Profile

Actions

Bug #18966

closed

PHP Warning, if a sql error occurs - Bug in class t3lib_db function sql_fetch_assoc

Added by Sonja Schubert almost 16 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2008-06-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

0008728.diff (2.08 KB) 0008728.diff Administrator Admin, 2009-08-27 17:53
8728_v2.diff (2.74 KB) 8728_v2.diff Administrator Admin, 2009-10-15 11:00

Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Feature #19336: Add an error and exception handler (backported from FLOW3)ClosedRupert Germann2008-09-16

Actions
Related to TYPO3 Core - Bug #21270: t3lib_admin::lostRecords produce errors / warningClosedSteffen Kamper2009-10-14

Actions
Related to TYPO3 Core - Bug #19306: Return value of debug_check_recordset is not usedClosedChris topher2008-09-09

Actions
Has duplicate TYPO3 Core - Bug #21037: Warning shows up in list mode when listing recordsClosedRupert Germann2009-09-11

Actions
Has duplicate TYPO3 Core - Bug #16896: uploading an image produces database errorClosedChris topher2007-01-24

Actions
Actions

Also available in: Atom PDF