Project

General

Profile

Actions

Bug #17347

closed

Database result not being tested for result

Added by Michael Cannon over 17 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2007-05-31
Due date:
% Done:

0%

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

Description

Since the database result isn't being check for a result, PHP Warnings show up. It's suggested to check for a result and if nothing there, return a false, 0, or empty array back to the calling method. This way PHP warnings go away and we're properly checking incoming variables and returning defined negatory results.

--
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/cannon/local/typo3_src-4.1.1/t3lib/class.t3lib_db.php on line 796
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/cannon/local/typo3_src-4.1.1/t3lib/class.t3lib_db.php on line 823
--

Sample fixes.

In t3lib/class.t3lib_db.php
line 796, from `return mysql_fetch_assoc($res);`
to `return $res ? mysql_fetch_assoc($res) : array();`

line 823, from `return mysql_fetch_assoc($res);`
to `return $res ? mysql_fetch_assoc($res) : false;`

Anywhere a mysql_fetch* or like is being called, incoming variable should be checked to exist.
(issue imported from #M5722)

Actions

Also available in: Atom PDF