diff -urN ../roundcubemail-1.6.1.orig/program/lib/Roundcube/rcube.php ./program/lib/Roundcube/rcube.php --- ../roundcubemail-1.6.1.orig/program/lib/Roundcube/rcube.php 2023-01-23 22:03:14.000000000 +0200 +++ ./program/lib/Roundcube/rcube.php 2023-04-12 11:52:46.063087000 +0300 @@ -1381,6 +1381,35 @@ } /** + * Format backtrace. + * + * @param array $backtrace Backtrace array + * @see debug_backtrace() + * @param int $limit Limit the number of stack frames formatted. By default (limit=0) it formats all stack frames. + */ + public static function debug_backtrace_as_string($backtrace, $limit = 0) + { + $i = 0; + $res = []; + $res[] = 'Stack trace:'; + foreach ($backtrace as $backtrace_item) { + if (($limit == 0) or ($i < $limit)) { + $res[] = sprintf("#%d %s(%d): %s%s%s()", + $i, + (!empty($backtrace_item['file']) ? $backtrace_item['file'] : ''), + (!empty($backtrace_item['line']) ? $backtrace_item['line'] : 0), + (!empty($backtrace_item['class']) ? $backtrace_item['class'] : ''), + (!empty($backtrace_item['type']) ? $backtrace_item['type'] : ''), + (!empty($backtrace_item['function']) ? $backtrace_item['function'] : '') + ); + $i++; + } + } + if (($limit == 0) or ($i < $limit)) $res[] = sprintf("#%d {main}", $i); + return(implode("\n", $res)); + } + + /** * Throw system error, with optional logging and script termination. * * @param array|Throwable|string|PEAR_Error $arg Error object, string or named parameters array: diff -urN ../roundcubemail-1.6.1.orig/program/lib/Roundcube/rcube_db.php ./program/lib/Roundcube/rcube_db.php --- ../roundcubemail-1.6.1.orig/program/lib/Roundcube/rcube_db.php 2023-01-23 22:03:14.000000000 +0200 +++ ./program/lib/Roundcube/rcube_db.php 2023-04-11 14:49:21.326443000 +0300 @@ -566,6 +566,7 @@ rcube::raise_error([ 'code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => $this->db_error_msg . " (SQL Query: $query)" + . "\n" . rcube::debug_backtrace_as_string(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)) . "\n thrown" ], true, false); } }