[BUGFIX] t3lib_db - expects parameter 1 to be resource, boolean given
authorMichael Klapper <development@morphodo.com>
Fri, 3 Aug 2012 10:23:35 +0000 (12:23 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 3 Aug 2012 11:35:07 +0000 (13:35 +0200)
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/13440
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/class.t3lib_db.php

index d4c0afb..d268535 100644 (file)
@@ -1386,43 +1386,43 @@ 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', 3);
-                               // 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);
+               }
+               $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', 3);
+                       // 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;
                        }
-
-                       return FALSE;
+                       t3lib_div::devLog($msg . '.', 'Core/t3lib_db', 3, $debugLogData);
                }
-               return TRUE;
+
+               return FALSE;
        }
 
        /**