Issue Bug Closed

#17347Database result not being tested for result

Michael Cannon 05/31/07, 16:41 updated 01/06/14, 11:41

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)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.