Bug #17946
closedEM: sql_free_result() on non-resources fails
0%
Description
If I install an extension which creates tables, then I get a warning message in the EM.
$GLOBALS['TYPO3_DB']->sql_free_result($res); should not be called after a CREATE TABLE statement.
$res = 1 in this case.
SC_mod_tools_em_index->main // SC_mod_tools_em_index->showExtDetails // SC_mod_tools_em_index->updatesForm // SC_mod_tools_em_index->checkDBupdates // t3lib_install->performUpdateQueries // t3lib_DB->admin_query
Change this to
} else if ($res != 1) {
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
function performUpdateQueries($arr,$keyArr) {$result = array();
if (is_array($arr)) {
foreach($arr as $key => $string) {
if (isset($keyArr[$key]) && $keyArr[$key]) {
$res = $GLOBALS['TYPO3_DB']->admin_query($string);
if ($res === false) {
$result[$key] = $GLOBALS['TYPO3_DB']->sql_error();
} else {
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
}
}
}
if (count($result) > 0) {
return $result;
} else {
return true;
}
}
--------------------
( ! ) Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /var/www/html/typo3-svn/TYPO3core/trunk/t3lib/class.t3lib_db.php on line 825
Call Stack
- Time Function Location
1 0.0003 {main}() /var/www/html/typo3-svn/TYPO3core/trunk/typo3/mod/tools/em/index.php:0
2 0.4299 SC_mod_tools_em_index->main() /var/www/html/typo3-svn/TYPO3core/trunk/typo3/mod/tools/em/index.php:54
3 0.4302 SC_mod_tools_em_index->showExtDetails() /var/www/html/typo3-svn/TYPO3core/trunk/typo3/mod/tools/em/class.em_index.php:558
4 0.7088 SC_mod_tools_em_index->updatesForm() /var/www/html/typo3-svn/TYPO3core/trunk/typo3/mod/tools/em/class.em_index.php:2078
5 0.7091 SC_mod_tools_em_index->checkDBupdates() /var/www/html/typo3-svn/TYPO3core/trunk/typo3/mod/tools/em/class.em_index.php:2257
6 1.2084 t3lib_install->performUpdateQueries() /var/www/html/typo3-svn/TYPO3core/trunk/typo3/mod/tools/em/class.em_index.php:4498
7 1.2227 t3lib_DB->sql_free_result() /var/www/html/typo3-svn/TYPO3core/trunk/t3lib/class.t3lib_install.php:747
8 1.2227 mysql_free_result () /var/www/html/typo3-svn/TYPO3core/trunk/t3lib/class.t3lib_db.php:825
(issue imported from #M7038)
Files
Updated by Oliver Hader almost 17 years ago
According to http://de3.php.net/mysql_query there are differet return values concerning the database action/modification that was performed.
Checking for the integer "1" would also be true on boolean values. A better comparison could be done with is_resource($res). And only if it's a valid resource, the sql_free_result() will be called...