Issue Bug Closed

#17946EM: sql_free_result() on non-resources fails

Franz Holzinger 12/22/07, 12:38 updated 08/06/10, 13:17

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
  1. 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)

Reviews 0

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