Review main Merged

69425[BUGFIX] Make logger usage PSR-3 compliant

crell CR +2 V +2 Hard +527 −317 updated 06/16/21, 15:21

Commit message

PSR-3 has specific rules around interpolation: Messages
may provide placeholders like {foo} and writers should
substitute these in the messages if a context array with
such a key is provided.
Let's use placeholders correctly.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Anja Leichsenring +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Anja Leichsenring +1
    • core-ci +1 CI

Issues 2

Files 54

Show 34 more files

Review log 5067

Show 2942 earlier messages
  1. crell uploaded patch set 1 06/09/21, 22:38

  2. crell marked it work in progress 06/09/21, 22:38

  3. crell commented on patch set 1 06/09/21, 22:39

    This change is ready for review.
    Still WIP, but I want to get it off my computer and see what parts of it the bot hates. Preliminary reviews welcome.
  4. crell marked it work in progress 06/09/21, 22:39

  5. core-ci voted on patch set 1 V -1 06/09/21, 22:46 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12258

  6. crell uploaded patch set 2 06/10/21, 16:09

  7. core-ci voted on patch set 2 V -1 06/10/21, 16:11 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12277

  8. crell uploaded patch set 3 06/10/21, 16:20

  9. core-ci voted on patch set 3 V -1 06/10/21, 16:34 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12278

  10. crell uploaded patch set 4 06/10/21, 22:38

  11. core-ci voted on patch set 4 V -1 06/10/21, 22:40 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12288

  12. crell uploaded patch set 5 06/11/21, 14:15

  13. core-ci voted on patch set 5 V -1 06/11/21, 14:18 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12305

  14. crell uploaded patch set 6 06/11/21, 15:02

  15. core-ci voted on patch set 6 V -1 06/11/21, 15:19 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12308

  16. crell uploaded patch set 7 06/11/21, 15:43

  17. core-ci voted on patch set 7 V -1 06/11/21, 15:55 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12311

  18. crell uploaded patch set 8 06/11/21, 16:17

  19. core-ci voted on patch set 8 V -1 06/11/21, 16:29 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12312

  20. crell uploaded patch set 9 06/11/21, 16:52

  21. core-ci voted on patch set 9 V -1 06/11/21, 17:00 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12313

  22. crell uploaded patch set 10 06/11/21, 21:05

  23. core-ci voted on patch set 10 V +1 06/11/21, 21:14 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12323

  24. crell marked it ready for review 06/11/21, 21:16

  25. Oli Bartsch commented on patch set 10 06/11/21, 22:09

    Hi Larry, I had a short read through the patch, but will dig deeper into it on the weekend. I already added some comments, mostly regarding changes which seem to be unrelated to the patch. Please always try to avoid such unrelated changes, especially in large patches like this. It makes reviewing much harder.

    EmailLoginNotification.php:106

    This seems to be unrelated. Also usages of this method do not reveal that this should be nullable. What makes you think that this should be nullable?

    Connection.php:107

    Seems to be unrelated.

    PageRepository.php:1011

    Seems to be unrelated.

    DatabaseWriter.php:33

    Seems to be unrelated.

    FileWriter.php:99

    If already changing this methods' signature, should we also add the return type?

    GeneralUtility.php:3543

    What's the reason for this change?

    ProductionExceptionHandler.php:33

    This seems to be unrelated.

    ValidatorTask.php:562

    Any specific reason for adding this inline annotation?
  26. crell commented on patch set 10 06/14/21, 12:14

    I'm generally following campground-rules: Leave it cleaner than you found it. So if there's trivial fixes in close proximity to where I'm already making a change, I'll fix it along the way. As long as it doesn't break anything I think that's reasonable. (Though one of these did break something for a bit, but it's already fixed now.)

    EmailLoginNotification.php:106 Reply

    The docblock says it accepts null, and it has a default value of null. Technically a default value of null without being nullable is soft-deprecated; there's been talk of making it an error but I don't think that's happened yet. So either it should be typed nullable or the docblock de-nulled and the default set to something not-null.

    DatabaseWriter.php:33 Reply

    Mm, left over from when I was still trying to change the table name, but I punted that to a future issue. I'll be doing it then anyway so I don't see a reason not to include it here. It's effectively a constant.

    FileWriter.php:99 Reply Unresolved

    Probably, although I've been a bit more gunshy about return values. I'm all for typing everything we possibly can so if it's safe to do, let's do. (Arguably that's backwards given the variance rules in PHP 7.4+.)

    GeneralUtility.php:3543 Reply

    Anything with an @ is a potential for issues, especially as it covers less in PHP *. Also, method_exists() is the more-precise and thus IMO more-correct API call to use here; what it's trying to do is verify that the method is there to be called, and give an error if the method doesn't exist. So check method_exists specifically.

    ValidatorTask.php:562 Reply

    IntelliJ/PHPStorm can't detect the type returned from makeInstance(), so it doesn't know that $fluidEmail has a setTemplate() method and complains about the next line. adding a type annotation here tells static analyzers "trust me, this is a FluidEmail, assume I'm right." (Avoiding makeInstance() would be even better, but that's a longer-term thing.)
  27. Markus Klein commented on patch set 10 06/14/21, 12:33

    ValidatorTask.php:562 Reply

    We use a PHPStorm Plugin for this: TYPO3 CMS ;-)
  28. crell commented on patch set 10 06/14/21, 12:40

    ValidatorTask.php:562 Reply

    Porque no los dos, as the kids say...
  29. Oli Bartsch commented on patch set 10 06/14/21, 13:35

    Reply

    In small patches, this surely will be ok. But as this patch proved, making unrelated changes can easily break something which is then really hard to debug. Luckily the testing framework found this before the patch got merged. Otherwise this had introduced a regression which would certainly have been difficult to find. Besides possible bugs, reviewing of such large patches already takes a lot of time. If one then also has to distinguish whether a change is relevant for the patch or not, it only makes the whole thing even more time-consuming. For sure, this is always a case-by-case thing (e.g. changing to type properties should be easy to detect). Just wanted to create awareness for it in general. :)

    EmailLoginNotification.php:106 Reply

    > Technically a default value of null without being nullable is soft-deprecated; > there's been talk of making it an error but I don't think that's happened yet. Do you have some reference for this? This sounds interesting, as for me those two are different things. TYPO3 often uses NULL as default value for the use of guard clauses, while not allowing NULL to be passed.

    GeneralUtility.php:3543 Reply

    Regarding the @ I'm fully with you. However, method_exists just checks for existence. In L:3549 this method is then called which triggers a fatal in case the method is not callable (e.g. not public).

    ValidatorTask.php:562 Reply

    Therefore, TYPO3 features the https://github.com/TYPO3/TYPO3.CMS/blob/master/dynamicReturnTypeMeta.json file. Together with the mentioned plugin, PHPStrom understands those calls, making the inline annotations superfluous.
  30. crell commented on patch set 10 06/14/21, 16:19

    EmailLoginNotification.php:106 Reply

    I checked and while it's been talked about, nothing has been implemented for it, it looks like. However, it is a mismatch for a type to specify that it requires a string, but could still sneak in a null. (That's why there's been talk of deprecating that, but it apparently hasn't happened yet.) Either way, the docblock currently says it's nullable, so either the type def or the docblock should be updated.

    GeneralUtility.php:3543 Reply

    (For posterity, we discussed elsewhere and I'm switching it back to is_callable() but without the @, as the latter is unnecessary.)

    ValidatorTask.php:562 Reply

    That helps PHPStorm, but not necessarily casual readers, or users of other IDEs. I can remove it if that's policy, but I think in these cases it's better to include explicit definitions in the source rather than relying on specific tooling.
  31. crell uploaded patch set 11 06/14/21, 16:19

  32. core-ci voted on patch set 11 V -1 06/14/21, 16:28 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12427

  33. crell uploaded patch set 12 06/14/21, 17:30

  34. core-ci voted on patch set 12 V +1 06/14/21, 17:41 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12431

  35. Anja Leichsenring commented on patch set 12 06/15/21, 17:39

    LanguagePackService.php:279

    a placeholder is missing here, is suspect it should be {request}?
  36. crell commented on patch set 12 06/15/21, 18:02

    LanguagePackService.php:279 Reply

    Yep, I forgot to convert the first %s. Will fix.
  37. crell uploaded patch set 13 06/15/21, 18:02

  38. core-ci voted on patch set 13 V +1 06/15/21, 18:13 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12463

  39. Anja Leichsenring voted on patch set 13 V +1 CR +1 06/15/21, 18:28

  40. Markus Klein commented on patch set 13 06/16/21, 07:43

    AbstractWriter.php:118

    I'm not sure about this. We do have some class names within the Core that exist multiple times. The full namespace is helpful then. Also the stacktrace is vital. I need it regularly to inspect problems. Maybe the writers should have an option, where I can selectively enable the stacktrace?
  41. Christian Kuhn commented on patch set 13 CR -1 06/16/21, 08:57

    on it.
  42. Christian Kuhn commented on patch set 13 06/16/21, 11:11

    will push an update soon.

    EmailLoginNotification.php:106 Reply

    fine with me.

    PasswordResetTest.php:34

    clever. we're not doing that often enough.

    Connection.php:107 Reply

    yes. but good catch. and probably no v10 backport, so ... keep it ...

    PageRepository.php:1011 Reply

    ok to do as drive-by. we fixed an issue here in a previous patch-set.

    PageRepository.php:1019

    uids instead of uuids, let's not use wording uuid when they aren't. and: no implode here? array of arrays is properly handled?

    DatabaseWriter.php:33 Reply

    Ack

    ProductionExceptionHandler.php:33 Reply

    but ok here.

    TypoScriptFrontendController.php:1171

    good!

    ValidatorTask.php:562 Reply

    In general, we rather remove those hints for makeInstance() calls when an instance of `Whatever::class` is retrieved and add it for things like makeInstance($myClassName) to make phpstan and friends happy. Note you don't need the big typo3 cms plugin (I don't use it), the 'dynamic return type plugin' is enough for phpstorm to understand makeInstance().
  1. Christian Kuhn commented on patch set 13 06/16/21, 11:11

    PageRepository.php:1019 Reply

    Done
  2. Christian Kuhn commented on patch set 13 06/16/21, 11:32

    AbstractExceptionHandler.php:88

    sidenote: this getIndpEnv() call (and the one below) could be dropped by accessing $globals['typo3_request']->getAttribute('normalizedParams') here -> single patch, please.
  3. Christian Kuhn commented on patch set 13 06/16/21, 12:15

    AbstractExceptionHandler.php:88 Reply

    Ack

    AbstractWriter.php:79

    sidenote: there's ArrayUtility::renumberKeysToAvoidLeapsIfKeysAreAllNumeric() as a similar helper that removes 'holes' in numeric keys ... *maybe* we could later move this method over there in case it gets additional usages.
  4. Markus Klein commented on patch set 13 CR -1 06/16/21, 12:49

    see my comment on stack traces
  5. Christian Kuhn commented on patch set 13 06/16/21, 12:53

    Reply Unresolved

    working on this currently.
  6. Christian Kuhn commented on patch set 13 06/16/21, 12:55

    AbstractExceptionHandler.php:96

    misses 'message' key.
  7. Christian Kuhn commented on patch set 13 06/16/21, 13:14

    AbstractExceptionHandler.php:91

    and we should add exception_code again, it's useful.

    AbstractExceptionHandler.php:96 Reply

    Done

    AbstractWriter.php:118 Reply

    No behaviour change. the message did not include full backtrace before, either, but data/context does. Example before patch from FileWriter: Wed, 16 Jun 2021 14:57:09 +0200 [CRITICAL] request="375fb151efa63" component="TYPO3.CMS.Core.Error.DebugExceptionHandler": Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1476107295: PHP Warning: Undefined array key "sub" in /var/www/local/coremaster/public/typo3/sysext/backend/Classes/Controller/AboutController.php line 121 | TYPO3\CMS\Core\Error\Exception thrown in file /var/www/local/coremaster/public/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 150. Requested URL: http://coremaster8.local.schwarzbu.ch/typo3/module/help/AboutAbout?token=--AnonymizedToken-- - {"TYPO3_MODE":"BE","exception":"TYPO3\\CMS\\Core\\Error\\Exception: PHP Warning:... FULL backtrace ... Example with patch: Wed, 16 Jun 2021 15:12:08 +0200 [CRITICAL] request="2861febd3e55d" component="TYPO3.CMS.Core.Error.DebugExceptionHandler": Core: Exception handler (WEB: BE): TYPO3\CMS\Core\Error\Exception, code #1476107295, file /var/www/local/coremaster/public/typo3/sysext/core/Classes/Error/ErrorHandler.php, line 150: PHP Warning: Undefined array key "sub" in /var/www/local/coremaster/public/typo3/sysext/backend/Classes/Controller/AboutController.php line 121 - {"mode":"WEB","application_mode":"BE","exception_class":"TYPO3\\CMS\\Core\\Error\\Exception","exception_code":1476107295,"file":"/var/www/local/coremaster/public/typo3/sysext/core/Classes/Error/ErrorHandler.php","line":150,"message":"PHP Warning: Undefined array key \"sub\" in /var/www/local/coremaster/public/typo3/sysext/backend/Classes/Controller/AboutController.p ... FULL backtrace ... So the only change is that a slight reformatting of the message, and full backtrace is still in data/context.
  8. Christian Kuhn uploaded patch set 14 06/16/21, 13:14

  9. Christian Kuhn commented on patch set 14 CR -1 06/16/21, 13:15

    fine with me codewise. will add an important.rst to point out the placeholder stuff.
  10. core-ci voted on patch set 14 V +1 06/16/21, 13:30 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12495

  11. Christian Kuhn uploaded patch set 15 06/16/21, 13:42

  12. crell voted on patch set 15 CR +1 06/16/21, 13:48

  13. core-ci voted on patch set 15 V +1 06/16/21, 13:53 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12496

  14. Christian Kuhn commented on patch set 15 CR -1 06/16/21, 14:12

    we'll push a version without the context sub-array stuff again, this may give headaches with monolog later, so we omit this detail.
  15. crell uploaded patch set 16 06/16/21, 14:27

  16. core-ci voted on patch set 16 V +1 06/16/21, 14:37 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12498

  17. Markus Klein commented on patch set 16 CR -1 06/16/21, 14:40

    DatabaseWriter.php:71

    where is $message used?
  18. crell commented on patch set 16 06/16/21, 14:44

    DatabaseWriter.php:71 Reply

    It's not. Leftover from previous drafts. Will remove.
  19. crell uploaded patch set 17 06/16/21, 14:44

  20. Christian Kuhn commented on patch set 17 06/16/21, 14:45

    DatabaseWriter.php:71 Reply

    note: this writer will see a bigger rewrite soon, anyways.
  21. Christian Kuhn voted on patch set 17 V +1 CR +1 06/16/21, 14:50

  22. core-ci voted on patch set 17 V +1 06/16/21, 14:55 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12499

  23. Anja Leichsenring voted on patch set 17 V +1 CR +1 06/16/21, 15:17

  24. Christian Kuhn voted on patch set 17 V +2 CR +2 06/16/21, 15:20

  25. Christian Kuhn merged patch set 18 06/16/21, 15:21