]> git.wh0rd.org - tt-rss.git/blobdiff - include/errorhandler.php
remove db_connect, db_close; CLI fixes
[tt-rss.git] / include / errorhandler.php
index bb60592b7c643ec4225b348cc21c7a5c097df43c..2c8d35f8371c4a8b2759d014642245910b50ad97 100644 (file)
@@ -6,6 +6,8 @@ require_once "classes/logger/sql.php";
 function ttrss_error_handler($errno, $errstr, $file, $line, $context) {
        global $logger;
 
+       if (error_reporting() == 0 || !$errno) return false;
+
        if (!$logger) $logger = new Logger_SQL();
 
        $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);
@@ -20,19 +22,16 @@ function ttrss_error_handler($errno, $errstr, $file, $line, $context) {
 function ttrss_fatal_handler() {
        global $logger;
 
-       $file           = "UNKNOWN FILE";
-       $errstr  = "UNKNOWN";
-       $errno   = E_CORE_ERROR;
-       $line           = -1;
-
        $error = error_get_last();
 
        if ($error !== NULL) {
-               $errno   = $error["type"];
+               $errno = $error["type"];
                $file = $error["file"];
                $line = $error["line"];
                $errstr  = $error["message"];
 
+               if (!$errno) return false;
+
                $context = debug_backtrace();
 
                $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);
@@ -40,9 +39,14 @@ function ttrss_fatal_handler() {
                if (!$logger) $logger = new Logger_SQL();
 
                if ($logger) {
-                       $logger->log_error($errno, $errstr, $file, $line, $context);
+                       if ($logger->log_error($errno, $errstr, $file, $line, $context)) {
+                               return true;
+                       }
                }
+               return false;
        }
+
+       return false;
 }
 
 register_shutdown_function('ttrss_fatal_handler');