69514[TASK] Clean up ErrorHandlers to remove legacy logger
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 6
- typo3/sysext/core/Classes/Core/Bootstrap.php+3 −3
- typo3/sysext/core/Classes/Error/ErrorHandler.php5+74 −50
- typo3/sysext/core/Classes/Error/ErrorHandlerInterface.php11+3 −3
- typo3/sysext/core/Configuration/DefaultConfiguration.php4+12 −0
- typo3/sysext/core/Tests/Functional/Error/ErrorHandlerTest.phpdeleted+0 −127
- typo3/sysext/core/Tests/Unit/Error/ErrorHandlerTest.php+7 −9
Review log 2026
Show 1 earlier messages
-
crell uploaded patch set 1 06/17/21, 18:53
-
core-ci voted on patch set 1 V -1 06/17/21, 18:56 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12560
-
crell uploaded patch set 2 06/17/21, 19:47
-
core-ci voted on patch set 2 V -1 06/17/21, 19:50 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12562
-
crell uploaded patch set 3 06/17/21, 19:54
-
core-ci voted on patch set 3 V -1 06/17/21, 20:07 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12563
-
Benni Mack commented on patch set 3 06/17/21, 20:50
-
crell uploaded patch set 4 06/18/21, 19:10
-
core-ci voted on patch set 4 V -1 06/18/21, 19:13 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12591
-
crell uploaded patch set 5 06/18/21, 19:17
-
core-ci voted on patch set 5 V +1 06/18/21, 19:29 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12592
-
crell commented on patch set 5 06/18/21, 21:07
ErrorHandlerInterface.php:56Reply UnresolvedNothing else in Core implements that interface currently. The types all come directly from PHP itself. And It's legal in PHP 7.2+ for a child class to drop parameter types from an interface. So those wouldn't break even existing code. -
Helmut Hummel commented on patch set 5 CR -1 06/20/21, 14:43
Thanks for touching this topic. This area (TYPO3 error handling) clearly needs some love. However I'm a bit undecided with this particular change. While it cleans up things, it either does too much (breaking changes) or too little (still some important topics are not touched) e.g. we still have a dependency to a logger/ log manager, which requires a hack in our bootstrap also we still allow to disable error handling by configuration or provide a custom implementation of the error handler, which in fact needs to replicate implementation details of TYPO3's current logging. I'd therefore suggest to completely rethink how TYPO3's error and exception handling is designed, instead of doing a refactoring of the code (which also incorporates some breaking changes nontheless)I haven't followed changes in this area very closely, so I might have missed some improvements. When this logging is removed, is there still a way to get errors logged, so that they appear in the belog backend module? Otherwise this would be a quite impactful change for some users.ErrorHandler.php:134Unresolvedif we are changing this area, it would make sense to throw an https://php.net/manual/en/class.errorexception.php here instead of our custom exception (or make our custom exception extend from ErrorExceptionErrorHandler.php:149configuration wise this is a breaking changeErrorHandlerInterface.php:60That is a breaking changeDefaultConfiguration.php:1493I don't think "depreceations" is a correct infix here -
crell commented on patch set 5 06/21/21, 14:51
Reply
The scope here, specifically, is "remove direct writes to sys_log", and in order to grok the code here to do that I needed to clean it up first. Having done so, frankly I also think we should consider throwing out ErrorHandler and ExceptionHandler entirely and adopting one of the 3rd party error frameworks instead (Booboo, Whoops, etc.), but that's even more API impacting than this patch is; I tried to keep this as minimal-changing as possible.Reply
Context: This is part of an effort to remove the direct writes to sys_log entirely and use the PSR-3 logging framework exclusively. At the moment, DatabaseWriter also writes to sys_log, so as long as the logger is wired to use Database Writer stuff will still end up there, and thus visible in the belog UI. There may be some processors to add to toss on more data, but that's the general idea.ErrorHandlerInterface.php:60ReplyWith PHP 7.4 variance rules, the parameters are fine. Only the return type is an issue (its variance is the other way around), and this doesn't strike me as a class that is oft-extended.DefaultConfiguration.php:1493ReplyTYPO3.CMS.deprecations is the existing log channel name that ErrorHandler was already using. I just kept that, but specified a log config for it explicitly. -
Benni Mack commented on patch set 5 06/30/21, 20:27
ErrorHandler.php:149ReplyDo you mean that we do not log to the Logger of __CLASS__ anymore? I think we could / should handle this with a SilentConfigurationUpdate script.ErrorHandlerInterface.php:60ReplyYes. Covariance seems to be OK for that, just tested this with a custom ErrorHandler of mine.DefaultConfiguration.php:1493Replyyes. I agree. the php_errors should go into a custom errors infix. Also: Shouldn't we just call the logger "php_errors" instead of "TYPO3.CMS.php_errors"? -
crell commented on patch set 5 07/01/21, 15:03
ErrorHandler.php:149ReplyWhat's a SilentConfigurationUpdate script?ErrorHandlerInterface.php:60ReplyAckDefaultConfiguration.php:1493Reply UnresolvedI have no strong preference on the name. I just followed the existing `TYPO3.CMS.deprecations` pattern. The new plan (since patch was posted) calls for a channel just called "php", so we could go all the way to that now and call it a day if you wanted. I don't fully grok the "infix" bit here, though. How should that get re-specified? -
Benni Mack commented on patch set 5 07/01/21, 19:01
Reply
@Helmut: Do you have any idea on how to approach this in a better fashion? -
Helmut Hummel commented on patch set 5 07/10/21, 10:45
Reply Unresolved
> Do you have any idea on how to approach this in a better fashion This topic is rather complicated as many areas are involved. 1. Log module needs to be able to at least show entries of DatabaseWriter, or DatabaseWriter must always write in a fashion that the UI can show such entries. 2. error and exception handler should be hardcoded and not be configurable and should be initialised right after the class loader. error handler should be able to receive multiple error observers (configured in DI), falling back default observer which only logs fatal errors that happen before DI is set up to a default location. exception handler should receive one exception renderer (configured in DI), falling back to a default renderer for exceptions that happen before DI is set up. Changes related to 2. will make the current ErrorHandler and its interface obsolete, thus it does not make sense to add breaking changes in that area only deprecate and eventually to throw away this API. If the scope is small, it should imho be kept small and less impactful. I think going for 1. would make sense, but this would likely not touch ErrorHandler, but DatabaseWriter and/or log module. I can't remember the details, but years ago I created this one with the goal that database writer should be able to write to write to sys_log in a fashion that log module can show it: https://review.typo3.org/c/Packages/TYPO3.CMS/+/56581 Not sure if there is still sth. useful in it, but maybe worth a peek.Reply
> so as long as the logger is wired to use Database Writer stuff will still end up there, and thus visible in the belog UI That is still not true, I checked with current sources to be sure. The DatabaseWriter writes to the sys_log table but the entries generated by the writer are not compatible with the log UI, thus end up not being visible in the log module. See e.g. https://stackoverflow.com/a/61701857/1285593 for a summary on the still current state of DatabaseWriterErrorHandler.php:149Reply Unresolved> Do you mean that we do not log to the Logger of __CLASS__ anymore Yes > I think we could / should handle this with a SilentConfigurationUpdate That could / would workErrorHandlerInterface.php:60ReplyDon't get it honestly. @Benni: your custom error hander did not override handleError()? Does not make much sense to me, as this is the method to override to implement custom behaviour. Your error handler implemented handleError()? How come you did not run into a fatal error complaining incompatible signatures because of the added return type? @Larry: "this doesn't strike me as a class that is oft-extended." Don't get that. Why would I extend the error handler, when I would not want to overwrite handleError()? How would I not run into a fatal when doing so? -
crell commented on patch set 5 07/12/21, 14:16
For context, the broader goal is to adopt Monolog for logging, and remove as many references to the old manual logger as possible: https://decisions.typo3.org/t/logging-plan-tng/705 So the original scope here was simply "use the PSR-3 logger instead of writing to the sys_log directly." Everything else here is essentially just me doing code cleanup so that I could understand what the code was going. (It was rather spaghetti-ish before.) The only real "change" here, API-wise, is the type declarations, which is just general good practice. All that said, I've also been pondering, as Helmut seems to be, if this work is worth it. Error handling is a commodity. There are a bunch of existing Error handling libraries for PHP already (I've started collecting a list), and Monolog even includes one itself. They run the gamut from fairly basic (Monolog's) to highly powerful and configurable. I don't know if it's within reasonable scope for v11, but we should probably plan to switch to some 3rd party error/exception handler sooner rather than later to just to get it out of the list of things we need to maintain. Benni, I don't know how you feel about that vis a vis what we do here. I'm going to hold off on rerolling this or https://review.typo3.org/c/Packages/TYPO3.CMS/+/69524 until we decide on the best way forward.Reply Unresolved
Addressing that is a WIP over here: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69663ErrorHandlerInterface.php:60ReplyI mean this isn't a class most sites will be overriding, IMO. A few might, but not most, so even if there is a nominal break it's area of effect is very small. PHP 7.4's variance rules (actually 7.2 and later in this case) allow you to *remove* (or make wider) a parameter type in a child class, and to *add* (or make narrower) a return type in a child class. So adding parameter types to an interface/base class will not generate a fatal. Adding a return type technically would, but the effort to fix it is minuscule and can be done in advance. (Viz, adding a return type now in v10 code would work fine, and then continue to work fine in v11.) -
Benni Mack commented on patch set 5 07/12/21, 18:24
ErrorHandlerInterface.php:60Reply@Helmut. Of course it extends handleError. Contravariance is huge, and no problem for us, and not breaking if we require PHP 7.4 (which we do). You can try it out for yourself: you can easily modify Core code to see how ErrorHandler with types breaks when ErrorHandlerInterface does not have types. and how nothing breaks if ErrorHandlerInterfaces has types, even if ErrorHandler has NO types. -
Helmut Hummel commented on patch set 5 07/20/21, 08:42
ErrorHandlerInterface.php:60Reply@Larry: I'm familiar with PHP's variance rules, thanks. > I mean this isn't a class most sites will be overriding, IMO How exactly did you check? I've see quite some sites overriding this class and even extensions providing overrides or own implementations. Yes it's not the 99% use case, but still worth a mention imho and for sure not a plain innocent "[TASK]" > A few might, but not most, so even if there is a nominal break it's area of effect is very small. I did not elaborate on the impact, true. If this break is decided to be small enough to get into a minor release, fine with me. I would mention it though, mark it as such and let the static code analyser we provide detect it. > Viz, adding a return type now in v10 code would work fine, and then continue to work fine in v11 fair enough and a good argument to do this change despite it is breaking. @Benni > You can try it out for yourself: you can easily modify Core code to see how ErrorHandler with types breaks when ErrorHandlerInterface does not have types. and how nothing breaks if ErrorHandlerInterfaces has types, even if ErrorHandler has NO types. You added the return type hint to the method in the interface and the core error handler did not break for you? I don't think this is what happened. -
Benni Mack commented on patch set 5 07/20/21, 10:20
ErrorHandlerInterface.php:60Reply UnresolvedAaaah, big sorry from my side! I only checked the contravariance part, not the covariance (return type), which is of course a big no go. -
Benni Mack uploaded patch set 6 08/25/21, 14:56
-
Benni Mack commented on patch set 6 08/25/21, 14:59
Just rebased the patch, kept the old logger and the old belog system (which we can now replace). -
core-ci voted on patch set 6 V -1 08/25/21, 15:09 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15607
-
Benni Mack abandoned the change 11/11/21, 14:25
will abandon this change for the time being, can be restored later once we tackle error handling again.
ErrorHandlerInterface.php:56