Review main Abandoned

73856[POC][TASK] Use Enum to group DB log messages

Benni Mack CR 0 V 0 Hard +438 −77 updated 02/10/23, 08:24

Commit message

DataHandler usually juggles with three
parts when doing logging:
* Action
* ErrorType (User Error etc)
* Text (non-translated)

It is very much painful to understand the combinations.

For this reason, a new Enum is introduced which
can then replace the various combinations, however,
there is much to do.

Ideally, this would also happen to ExtendedFileUtility
at the same time, and then we can slowly migrate
our Log functionality to

a) better labels / translations within the Enum
b) simplify the log() calls

Review

  • Code review CR 0
  • Verified V 0

Files 2

Review log 911

  1. Benni Mack uploaded patch set 1 03/08/22, 12:02

  2. core-ci voted on patch set 1 V -1 03/08/22, 12:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24712

  3. Mathias Brodala commented on patch set 1 03/08/22, 13:16

    LogMessages.php:29

    It's great that we make full use of PHP 8.1, but: 1. Should we continue to use our Enumeration base class for consistency? 2. Do we take into account that this makes backports to TYPO3v11 harder?
  4. Benni Mack uploaded patch set 2 03/08/22, 14:33

  5. Benni Mack commented on patch set 2 03/08/22, 14:38

    LogMessages.php:29 Reply

    1. Our Enumeration Base Class can basically be deprecated with the introduction of Enums, as they are more powerful and solve the same functionality out-of-the-box. 2. Well, to be honest, yes. If that's our main concern, we do have a problem. Just by trying out this patch, I found 12 separate small issues regarding logging we have with DataHandler, and in the end, we need to make all of DataHandler more maintainable. There are two options: a) try to refactor from the inside - having a bit work with backports, b) building a new API / Shell around DataHandler. Currently my main focus is actually decoupling of BackendUser (->log()/writeLog()) from DataHandler so DataHandler can be used in a more standalone fashion. I actually don't know how to proceed otherwise, as I'm very much left alone, since nobody wants to do the dirty work (e.g. logging) in such areas (a.k.a. "just use monolog and we're done"), and I've been pondring on this for years. Do you have any hints on how to proceed otherwise? I mean, even if I'd use "non-Enum" we'd still would need to centralize our DataHandler logging somewhere to find out if e.g. argument #4 is not even set at all...
  6. core-ci voted on patch set 2 V -1 03/08/22, 14:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24714

  7. Mathias Brodala commented on patch set 2 03/08/22, 14:50

    LogMessages.php:29 Reply

    Notice any work/improvement on shrinking/refactoring the DataHandler is awesome. I just wanted to be sure that we are aware of the implications (and have them kind of documented in public). So _if_ this is backported at all, we'll need to use our own Enumeration for TYPO3v11. I'd rather not do this prematurely though since these two could get out of sync.
  8. Benni Mack commented on patch set 2 03/08/22, 16:05

    LogMessages.php:29 Reply

    Yeah, this patch will take time. I will create a bunch of pre-patches before, and I'm not sold on the "enum" logic yet, but it helps to get an overview of what is broken... First one for main is this one btw. https://review.typo3.org/c/Packages/TYPO3.CMS/+/72818 Also see https://review.typo3.org/c/Packages/TYPO3.CMS/+/70163 which will also be a possibility.
  9. Benni Mack marked it work in progress 03/11/22, 18:58

  10. crell commented on patch set 2 04/21/22, 15:12

    DataHandler.php:869 Unresolved

    It seems like it would be easier to go ahead and add a different log method that took the enum as a whole object, rather than breaking it out here. Though at this point I question if an Enum is the right tool, and it should just be a typed object instead to allow for easier expansion. (Maybe this goes all the way to a command pattern, given the discussion around a queue/command bus?)

    LogMessages.php:31 Unresolved

    Please use CamelCase for enum cases. That's what's in the RFC, and will almost certainly be in the eventual FIG coding standards. They're also more readable than all caps.
  11. Benni Mack abandoned the change 02/10/23, 08:24