]> git.wh0rd.org - tt-rss.git/commitdiff
error handler: do not log last query, truncate error message to a smaller length
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Wed, 17 Feb 2016 13:42:13 +0000 (16:42 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Wed, 17 Feb 2016 13:42:13 +0000 (16:42 +0300)
classes/db/mysqli.php
classes/db/pgsql.php
include/errorhandler.php
include/functions.php

index eef500f776d006903b2051cb8e73a995b33eaeb5..c685b75a02c8e30db2f8d9bdd016b426861e9633 100644 (file)
@@ -24,10 +24,6 @@ class Db_Mysqli implements IDb {
        }
 
        function query($query, $die_on_error = true) {
-               global $last_query;
-
-               if (strpos($query, "ttrss_error_log") === FALSE) $last_query = $query;
-
                $result = @mysqli_query($this->link, $query);
                if (!$result) {
                        $error = @mysqli_error($this->link);
index 7bdcb7e9d578678b6740aeab12df94767f586e35..6b772d9e1de47e1d444f2dc8d20b7eec1f0ee7f3 100644 (file)
@@ -35,10 +35,6 @@ class Db_Pgsql implements IDb {
        }
 
        function query($query, $die_on_error = true) {
-               global $last_query;
-
-               if (strpos($query, "ttrss_error_log") === FALSE) $last_query = $query;
-
                $result = @pg_query($this->link, $query);
 
                if (!$result) {
index 8189feafba55d58e1752b767572f46673cce820a..f757b68d1cbbb3ae2a0111c9daa29ff101940239 100644 (file)
@@ -33,14 +33,13 @@ function format_backtrace($trace) {
 
 function ttrss_error_handler($errno, $errstr, $file, $line, $context) {
        global $logger;
-       global $last_query;
 
        if (error_reporting() == 0 || !$errno) return false;
 
        $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);
 
-       if ($last_query) $errstr .= " [Last query: $last_query]";
        $context = format_backtrace(debug_backtrace());
+       $errstr = truncate_middle($errstr, 16384, " (...) ");
 
        if (class_exists("Logger"))
                return Logger::get()->log_error($errno, $errstr, $file, $line, $context);
index b558b0e6c539004b0ee23a5fe061debe3c95f39b..d43943966c320b539a3be3ac478b0a9c88572c90 100755 (executable)
                }
        }
 
+       // is not utf8 clean
+       function truncate_middle($str, $max_len, $suffix = '&hellip;') {
+               if (strlen($str) > $max_len) {
+                       return substr_replace($str, $suffix, $max_len / 2, mb_strlen($str) - $max_len);
+               } else {
+                       return $str;
+               }
+       }
+
        function convert_timestamp($timestamp, $source_tz, $dest_tz) {
 
                try {