89244[BUGFIX] Autowire `LoggerInterface` for `inject*()` methods
Commit message
Review
-
Code review CR +2 Done
- Helmut Hummel +2
- Anja Leichsenring +1
- Stefan Bürk +1
-
Verified V +2 Done
- Helmut Hummel +2
- Oliver Klee +1
- Anja Leichsenring +1
- core-ci +1 CI
Issues 1
Files 19
- typo3/sysext/core/Classes/DependencyInjection/AutowireInjectMethodsPass.php+43 −1
- typo3/sysext/core/Classes/DependencyInjection/LogChannelExtractor.phpnew+47 −0
- typo3/sysext/core/Classes/DependencyInjection/LoggerAwarePass.php1+2 −16
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/ConstructorAttributeChannelTester.php+3 −1
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/ConstructorClassAttributeChannelTester.phpnew+34 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/ConstructorWithoutAttributeTester.phpnew+32 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/GrandParentInjectMethodClassAttributeChannelTester.phpnew+25 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/GrandParentInjectMethodNoClassAttributeTester.phpnew+23 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/InjectMethodAttributeChannelTester.php1new+38 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/InjectMethodClassAttributeChannelTester.phpnew+39 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/InjectMethodWithoutAttributeChannelTester.phpnew+37 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/LoggerAwareClassAttributeChannelTester.php+3 −1
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/LoggerAwareClassWithoutAttributeChannelTester.php1new+33 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/ParentInjectMethodAttributeChannelTester.php1new+31 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/ParentInjectMethodClassAttributeChannelTester.phpnew+25 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Classes/ParentInjectMethodWithoutAttributeChannelTester.phpnew+23 −0
- typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger/Configuration/Services.yaml1+2 −5
- typo3/sysext/core/Tests/Functional/Log/LoggerAwareChannelTest.phpdeleted+0 −82
- typo3/sysext/core/Tests/Functional/Log/LoggerInterfaceTest.phpnew+221 −0
Review log 3954
Show 2129 earlier messages
-
Stefan Bürk uploaded patch set 1 04/27/25, 12:15
-
core-ci voted on patch set 1 V +1 04/27/25, 12:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78226
-
Stefan Bürk updated the commit message in patch set 2
V +104/27/25, 12:52 -
core-ci voted on patch set 2 V +1 04/27/25, 13:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78227
-
Lina Wolf commented on patch set 2 04/27/25, 14:16
I like how you added tests for the different use cases (method injection, constructor injection, extending a class the uses constructor injection)AutowireLoggerInterfaceInjectMethodPass.php:91Even TYPO3 12.4 requires PHP 8.1 and later. Why is this comment (and the test for that matter) needed? -
Stefan Bürk commented on patch set 2 04/27/25, 14:23
AutowireLoggerInterfaceInjectMethodPass.php:91ReplyCopy & pasta from the other compile pass. But correct, not needed. Can be simplified in all places, I guess. Going to have a look latern. Thanks for pointing this out. -
Stefan Bürk uploaded patch set 3
V +104/27/25, 15:14 -
core-ci voted on patch set 3 V +1 04/27/25, 15:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78239
-
Lina Wolf commented on patch set 3 04/27/25, 15:23
AutowireLoggerInterfaceInjectMethodPass.php:91ReplyDone -
Lina Wolf commented on patch set 3 CR +1 V +1 04/27/25, 15:24
Code looks good and works. Automatic tests are adjusted -
Benjamin Franzke commented on patch set 3 04/28/25, 06:12
Btw, this is already supported via `LoggerAwareInterface` and `LoggerAwareTrait` and therefore until now not supported in `inject*` methods. Using `LoggerAwareTrait` ensures that nodes in the hierachy (base class, extending class) have access to the logger, in case both base class and extending class want to use the logger. I understand the desire (although I still don't like it) to normalize inject* with constructor based injection, but I do not agree that this is a) a good idea in general for abstract classes in comparison to `LoggerAwareInterface` and b) given the `LoggerAwareInterface` this is not a priority BUGFIX imho. Fine for me for v13 anyway, but I haven't had a look at the code yet, looks like quite some duplication of existing logic. -
Stefan Bürk commented on patch set 3 04/28/25, 08:01
Reply
I used `AutowireInjectMethodsPass` as base for the clone and incorporated things from `LoggerInterfacePass` for the new pass, only dealing for the interface. I tried to avoid mixing a special case into the `AutowireInjectMethodsPass`, but could be possible. If you would prefere it there. -
Oliver Klee updated the commit message in patch set 4
CR +1V +104/28/25, 11:18 -
core-ci voted on patch set 4 V +1 04/28/25, 11:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78271
-
Stefan Froemken commented on patch set 4 CR +1 V +1 06/13/25, 08:14
Wow. This is very good work. I have tested it within my own little cars extension and also tried adding injectLogger into Extbase ActionController directly. Works! From my point of view: happy merging.LoggerAwarePass.php:73Thank you for taking care of that, too ;-)InjectMethodAttributeChannelTester.php:29Wow...Never seen that. Awesome.LoggerAwareClassWithoutAttributeChannelTester.php:25Thank you for also taking care of LoggerAware implementation.ParentInjectMethodAttributeChannelTester.php:25Ahh...this is for overwriting the logger with inject-method in parent class with another channel output. You thought on everything. Why it is not already merged ;-)Services.yaml:7Both are removed because of using PHP attribute #Autoconfigure. Nice. -
Stephan Großberndt updated the commit message in patch set 5
CR +1V +106/13/25, 08:28 -
Stephan Großberndt commented on patch set 5 06/13/25, 08:35
This sentence from the commit message does not make sense to me yet: Making this compatible to `\Psr\Log\LoggerInterface` and inject service instances properly configured TYPO3 did not configured a single alias but ensures to instantiate a suiting logger instance for the class when injecting the interface as constructor argument or using the `\Psr\Log\LoggerAwareInterface` on a class leading to the case that no service for `LoggerInterface` can be wired automatically for inject methods. Also the sentence starting with "Usual traps for develops was to " should rather be something like "A usual trap for developers was to " ? -
core-ci voted on patch set 5 V +1 06/13/25, 08:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/80278
-
Lina Wolf commented on patch set 5 12/09/25, 12:24
Reply
@ben@bnf.dev the LoggerAwareTrait has the disadvantage of that it is breaking. So you cannot use it if there might be Classes that are extending your (abstract) class. https://review.typo3.org/c/Packages/TYPO3.CMS/+/91984 If for example the Extbase ActionController would now start to use the LoggerAwareTrait, it would be breaking for any class which extends the ActionController and uses the trait as traits can only be appliedf once. I would be really happy if we could find a solution here to move forward. In https://review.typo3.org/c/Packages/TYPO3.CMS/+/91984 I only implemented the interface and then defined the getter methods myself, but I just think beeing able to inject a Logger would be so much more straight forward -
Benjamin Franzke commented on patch set 5 04/15/26, 11:58
Reply
Hey I'm very sorry this received no feedback from my side for so long. I actually don't even know what my reservations where and would like to resolve this comment now. I'm fine with this from a structural view (iirx correctly my primary wish was that the implementation is not duplicated, but we can look into that). -
Stefan Bürk uploaded patch set 6
V +104/18/26, 00:11 -
core-ci voted on patch set 6 V -1 04/18/26, 00:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100427
-
core-ci commented on patch set 6 04/18/26, 01:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100427
-
core-ci voted on patch set 6 V +1 04/18/26, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100427
-
Stefan Bürk updated the commit message in patch set 7
V +104/19/26, 10:16 -
Stefan Bürk commented on patch set 7 04/19/26, 10:17
Reply
Done. Reworded whole commit message, hope it's better now. -
Stefan Bürk marked it ready for review 04/19/26, 10:17
-
Anja Leichsenring updated the commit message in patch set 8 04/19/26, 10:22
-
Anja Leichsenring voted on patch set 8 CR +1 V +1 04/19/26, 10:22
-
Stefan Bürk updated the commit message in patch set 9
CR +1V +104/19/26, 10:26 -
core-ci voted on patch set 7 V +1 04/19/26, 10:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100477
-
core-ci voted on patch set 8 V +1 04/19/26, 10:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100478
-
core-ci voted on patch set 9 V +1 04/19/26, 10:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100479
-
Helmut Hummel commented on patch set 9 04/19/26, 10:51
AutowireLoggerInterfaceInjectMethodPass.php:86This one now takes over autowiring for ALL inject methods. so why would we keep AutowireInjectMethodsPass?AutowireLoggerInterfaceInjectMethodPass.php:96this loop does not loopAutowireLoggerInterfaceInjectMethodPass.php:105this loop does not loop -
Helmut Hummel uploaded patch set 10
V +104/19/26, 11:25 -
core-ci voted on patch set 10 V +1 04/19/26, 11:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100482
-
Oliver Klee voted on patch set 10 V +1 04/19/26, 11:35
-
Stefan Bürk commented on patch set 9 CR -2 04/19/26, 11:44
Copied votes on follow-up patch sets have been updated: * Code-Review-2 has been copied to patch set 10 (copy condition: "changekind:NO_CHANGE OR is:MIN").AutowireLoggerInterfaceInjectMethodPass.php:86ReplyThanks, good point. I thought the early return condition in L73-75: ``` if (!($type instanceof \ReflectionNamedType && $type->getName() === LoggerInterface::class)) { continue; } ``` would avoid that, but there I was wrong. I'm trying to move this into the generic `AutowireInjectMethodsPass` now, @ben@bnf.dev also asked for something similar. -
Helmut Hummel uploaded patch set 11
V +104/19/26, 11:48Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**") -
Helmut Hummel commented on patch set 11 04/19/26, 11:51
AutowireLoggerInterfaceInjectMethodPass.php:86ReplyDoneAutowireLoggerInterfaceInjectMethodPass.php:96ReplyDoneAutowireLoggerInterfaceInjectMethodPass.php:105ReplyDone -
Stefan Bürk voted on patch set 11 CR 0 04/19/26, 11:52
-
Helmut Hummel updated the commit message in patch set 12 04/19/26, 11:52
-
Helmut Hummel commented on patch set 11 04/19/26, 11:52
Reply
Done -
Helmut Hummel updated the commit message in patch set 13 04/19/26, 11:58
-
core-ci voted on patch set 11 V +1 04/19/26, 11:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100483
-
core-ci voted on patch set 12 V +1 04/19/26, 12:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100484
-
core-ci voted on patch set 13 V +1 04/19/26, 12:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100485
-
Stefan Bürk commented on patch set 13 CR +1 04/19/26, 12:11
I'm fine with Helmuts changes. Thanks @typo3@helhum.io -
Helmut Hummel voted on patch set 13 CR +1 V +1 04/19/26, 12:13
-
Anja Leichsenring voted on patch set 13 CR +1 V +1 04/19/26, 12:18
-
Oliver Klee voted on patch set 13 V +1 04/19/26, 13:44
-
Helmut Hummel voted on patch set 13 CR +2 V +2 04/19/26, 15:13
-
Helmut Hummel merged patch set 14 04/19/26, 15:13