Project

General

Profile

Actions

Bug #17946

closed

EM: sql_free_result() on non-resources fails

Added by Franz Holzinger almost 17 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
Start date:
2007-12-22
Due date:
% Done:

0%

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

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)

Files

7038.diff (466 Bytes) 7038.diff Administrator Admin, 2007-12-22 12:52
0007038.patch (486 Bytes) 0007038.patch Administrator Admin, 2007-12-26 16:51
Actions #1

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

Actions #2

Updated by Oliver Hader almost 17 years ago

Committed to SVN Trunk (rev. 2859).

Actions

Also available in: Atom PDF