From f8eaef228101f1873f61c02946c11dd2211ca97b Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 20 Dec 2008 18:05:47 +0100 Subject: [PATCH] Log SQL errors. Signed-off-by: Florent Bruneau --- classes/xdb.php | 5 +++++ modules/core.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/classes/xdb.php b/classes/xdb.php index d012981..a51e210 100644 --- a/classes/xdb.php +++ b/classes/xdb.php @@ -113,6 +113,11 @@ class XDB } if ($globals->debug) { $text .= '
' . pl_entities(XDB::_reformatQuery($query)) . '
'; + } else { + $file = fopen($globals->spoolroot . '/spool/tmp/query_errors', 'a'); + fwrite($file, '
' . pl_entities(XDB::_reformatQuery($query)) . '
' + . '
' . XDB::$mysqli->error . '
' . "\n"); + fclose($file); } Platal::page()->kill($text); exit; diff --git a/modules/core.php b/modules/core.php index 8792c62..fa54116 100644 --- a/modules/core.php +++ b/modules/core.php @@ -30,6 +30,7 @@ class CoreModule extends PLModule 'send_bug' => $this->make_hook('bug', AUTH_COOKIE), 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'), 'kill_sessions' => $this->make_hook('kill_sessions', AUTH_COOKIE, 'admin'), + 'sql_errors' => $this->make_hook('sqlerror', AUTH_COOKIE, 'admin'), 'get_rights' => $this->make_hook('get_rights', AUTH_MDP, 'admin'), 'wiki_help' => $this->make_hook('wiki_help', AUTH_PUBLIC), @@ -191,6 +192,21 @@ class CoreModule extends PLModule echo MiniWiki::wikiToHtml($text, $action == 'title'); exit; } + + function handler_sqlerror(&$page, $clear = null) { + global $globals; + $file = @fopen($globals->spoolroot . '/spool/tmp/query_errors', 'r'); + if ($file !== false) { + echo ''; + fpassthru($file); + fclose($file); + echo ''; + } + if ($clear == 'clear') { + @unlink($globals->spoolroot . '/spool/tmp/query_errors'); + } + exit; + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -- 2.1.4