Commit 6d486221 authored by Michael Klapper's avatar Michael Klapper Committed by Christian Kuhn
Browse files

[BUGFIX] t3lib_db - expects parameter 1 to be resource, boolean given

The method t3lib_db::debug_check_recordset should use
"is_resource" to be sure we have a proper database resource object.

Change-Id: I18f25760d53d3bd3d8e396b40dbf3727b3bf33c8
Fixes: #39509
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/13438
Reviewed-by: Michael Klapper
Tested-by: Michael Klapper
Reviewed-by: Oliver Klee
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
parent 0627e130
......@@ -1380,47 +1380,47 @@ class t3lib_DB {
}
/**
* Checks if recordset is valid and writes debugging inormation into devLog if not.
* Checks if record set is valid and writes debugging information into devLog if not.
*
* @param resource $res Recordset
* @return boolean <code>FALSE</code> if recordset is not valid
* @param resource|boolean $res record set
* @return boolean TRUE if the record set is valid, FALSE otherwise
*/
function debug_check_recordset($res) {
if (!$res) {
$trace = FALSE;
$msg = 'Invalid database result resource detected';
$trace = debug_backtrace();
array_shift($trace);
$cnt = count($trace);
for ($i = 0; $i < $cnt; $i++) {
// Complete objects are too large for the log
if (isset($trace['object'])) {
unset($trace['object']);
}
if (is_resource($res)) {
return TRUE;
}
$msg = 'Invalid database result resource detected';
$trace = debug_backtrace();
array_shift($trace);
$cnt = count($trace);
for ($i = 0; $i < $cnt; $i++) {
// Complete objects are too large for the log
if (isset($trace['object'])) {
unset($trace['object']);
}
$msg .= ': function t3lib_DB->' . $trace[0]['function'] . ' called from file ' .
substr($trace[0]['file'], strlen(PATH_site) + 2) . ' in line ' .
$trace[0]['line'];
t3lib_div::sysLog(
$msg . '. Use a devLog extension to get more details.',
'Core/t3lib_db',
t3lib_div::SYSLOG_SEVERITY_ERROR
}
$msg .= ': function t3lib_DB->' . $trace[0]['function'] . ' called from file ' .
substr($trace[0]['file'], strlen(PATH_site) + 2) . ' in line ' .
$trace[0]['line'];
t3lib_div::sysLog(
$msg . '. Use a devLog extension to get more details.',
'Core/t3lib_db',
t3lib_div::SYSLOG_SEVERITY_ERROR
);
// Send to devLog if enabled
if (TYPO3_DLOG) {
$debugLogData = array(
'SQL Error' => $this->sql_error(),
'Backtrace' => $trace,
);
// Send to devLog if enabled
if (TYPO3_DLOG) {
$debugLogData = array(
'SQL Error' => $this->sql_error(),
'Backtrace' => $trace,
);
if ($this->debug_lastBuiltQuery) {
$debugLogData = array('SQL Query' => $this->debug_lastBuiltQuery) + $debugLogData;
}
t3lib_div::devLog($msg . '.', 'Core/t3lib_db', 3, $debugLogData);
if ($this->debug_lastBuiltQuery) {
$debugLogData = array('SQL Query' => $this->debug_lastBuiltQuery) + $debugLogData;
}
return FALSE;
t3lib_div::devLog($msg . '.', 'Core/t3lib_db', 3, $debugLogData);
}
return TRUE;
return FALSE;
}
/**
......@@ -1517,4 +1517,4 @@ class t3lib_DB {
}
}
?>
\ No newline at end of file
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment