From: Dmitry Dulepov Date: Sat, 2 Dec 2006 07:40:16 +0000 (+0000) Subject: t3lib_db: added calls to t3lib_div::sysLog() and t3lib_div::devLog() if recordset... X-Git-Tag: TYPO3_4-1-0RC1~140 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/c8610679fb90fdb68bffaf07d2b0e6e7a029a8a0 t3lib_db: added calls to t3lib_div::sysLog() and t3lib_div::devLog() if recordset is not valid git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1840 709f56b5-9817-0410-a4d7-c38de5d9e867 --- diff --git a/ChangeLog b/ChangeLog index 6d8d3b8e1f61..bc042fba3cf6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-12-02 Dmitry Dulepov + + * t3lib_db: added calls to t3lib_div::sysLog() and t3lib_div::devLog() if recordset is not valid + 2006-12-01 Kasper Skårhøj * Additionsl to FlexFormTools diff --git a/t3lib/class.t3lib_db.php b/t3lib/class.t3lib_db.php index 8bd17ef8d8ff..e4dd60372ecc 100755 --- a/t3lib/class.t3lib_db.php +++ b/t3lib/class.t3lib_db.php @@ -787,6 +787,7 @@ class t3lib_DB { * @return integer Number of resulting rows. */ function sql_num_rows($res) { + $this->debug_check_recordset($res); return mysql_num_rows($res); } @@ -799,6 +800,7 @@ class t3lib_DB { * @return array Associative array of result row. */ function sql_fetch_assoc($res) { + $this->debug_check_recordset($res); return mysql_fetch_assoc($res); } @@ -812,6 +814,7 @@ class t3lib_DB { * @return array Array with result rows. */ function sql_fetch_row($res) { + $this->debug_check_recordset($res); return mysql_fetch_row($res); } @@ -824,6 +827,7 @@ class t3lib_DB { * @return boolean Returns TRUE on success or FALSE on failure. */ function sql_free_result($res) { + $this->debug_check_recordset($res); return mysql_free_result($res); } @@ -859,6 +863,7 @@ class t3lib_DB { * @return boolean Returns TRUE on success or FALSE on failure. */ function sql_data_seek($res,$seek) { + $this->debug_check_recordset($res); return mysql_data_seek($res,$seek); } @@ -872,6 +877,7 @@ class t3lib_DB { * @return string Returns the name of the specified field index */ function sql_field_type($res,$pointer) { + $this->debug_check_recordset($res); return mysql_field_type($res,$pointer); } @@ -1096,6 +1102,27 @@ class t3lib_DB { )); } } + + /** + * Checks if recordset is valid and writes debugging inormation into devLog if not. + * + * @param resource $res Recordset + * @return boolean false if recordset is not valid + */ + function debug_check_recordset($res) { + if (!$res) { + t3lib_div::sysLog('Invalid database recordset detected. Install and enable devLog extension to get a full stack trace!', 'Core', 3); + $trace = false; + if (version_compare(phpversion(), '4.3.0', '>=')) { + $trace = debug_backtrace(); + array_shift($trace); + } + t3lib_div::devLog('Invalid recordset detected', 'Core/t3lib_db', 3, $trace); + return false; + } + return true; + } + }