Project

General

Profile

Actions

Feature #68785

closed

Log Fatal Errors

Added by Robert Vock over 9 years ago. Updated over 9 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Logging
Target version:
-
Start date:
2015-08-06
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Currently the TYPO3 ErrorHandler does not log FatalErrors to the sys_log-table. This happens because FatalErrors stop script execution.

It is easy to log this errors, too, if you register a shutdown function, which checks error_get_last.

Add this code to the constructor of \TYPO3\CMS\Core\Error\ErrorHandler

register_shutdown_function(function() {
    $error = error_get_last();
    if ($error['type'] & E_ERROR) {
        $this->handleError($error['type'], $error['message'], $error['file'], $error['line']);
    }
});

The handleError method should be adjusted and also check for E_ERROR, not only E_USER_ERROR:

$errorLevels = array(
    E_ERROR => 'Fatal Error',
    E_WARNING => 'Warning',
    E_NOTICE => 'Notice',
    E_USER_ERROR => 'User Error',
    E_USER_WARNING => 'User Warning',
    E_USER_NOTICE => 'User Notice',
    E_STRICT => 'Runtime Notice',
    E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
    E_DEPRECATED => 'Runtime Deprecation Notice'
);
[...]
switch ($errorLevel) {
    case E_ERROR:
    case E_USER_ERROR:
    case E_RECOVERABLE_ERROR:
        $severity = 2;
        break;
    case E_USER_WARNING:
    case E_WARNING:
        $severity = 1;
        break;
    default:
        $severity = 0;
}

Actions #1

Updated by Gerrit Code Review over 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42307

Actions #2

Updated by Christian Kuhn over 9 years ago

Mmmh, this is probably way more complicated than it sounds at first glance: We integrated this to the install tool and it turned out to be relatively hard to stabilize even in the relatively good encapsulated install tool scope.

There are plenty of problems: the shutdown function shouldn't have dependencies, eg. writing to db is a problem since the db connection may have failed already. even file writing is not always trivial.

Additionally, one could argue that a fatal in PHP should be handled by PHP itself and not by the application in general and thus logging sholud be configured via the top level php ini options. This is rather task / scope / concern on hosting level and not of the application.

At the moment I'd tend to say "nah, don't do it".

Actions #3

Updated by Frederic Gaus over 9 years ago

  • Status changed from Under Review to Rejected

This has been discussed in the core team and the conclusion was to not include this patch. The reasons have been explained by Christian. Thus I reject the patch. You think this is the wrong discussion? Then we would be very happy if you would join us on slack and discuss the topic with us!

Thanks so much for your effort to make TYPO3 even better!

Actions

Also available in: Atom PDF