diff --git a/include/class.osticket.php b/include/class.osticket.php index fd46d21346928ca443ed56f1842e15e9a35bb27e..467831d5b6e4a10720010d3a5f2a223a91257087 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -264,6 +264,10 @@ class osTicket { if($alert && !$this->getConfig()->alertONSQLError()) $alert =false; + $e = new Exception(); + $bt = str_replace(ROOT_DIR, '(root)/', $e->getTraceAsString()); + $error .= "\n\n---- Backtrace ----\n".$bt; + return $this->log(LOG_ERR, $title, $error, $alert); } diff --git a/include/mysqli.php b/include/mysqli.php index 737fd3a065795c007911a0abb663e103c8b80567..8b06a1742038547ca38b816485bed1e48f707193 100644 --- a/include/mysqli.php +++ b/include/mysqli.php @@ -235,8 +235,15 @@ function db_field_type($res, $col=0) { } function db_prepare($stmt) { - global $__db; - return $__db->prepare($stmt); + global $ost, $__db; + + $res = $__db->prepare($stmt); + if (!$res && $ost) { + // Include a backtrace in the error email + $msg='['.$stmt."]\n\n".db_error(); + $ost->logDBError('DB Error #'.db_errno(), $msg); + } + return $res; } function db_connect_error() {