Review main Abandoned

91984[FEATURE] Provide `$this->logger` in Extbase ActionController

Lina Wolf CR +1 V -1 Normal +198 −2 updated 10/25/26, 17:38

Commit message

Extbase ActionController now receives a PSR-3 compatible logger
instance automatically. A new protected property `$this->logger`
is available to all Extbase controllers without requiring
LoggerAwareInterface or LoggerAwareTrait in the controller itself.

The implementation intentionally does not use LoggerAwareTrait in
ActionController. Using the trait in the parent class would cause
collisions with existing Extbase controllers that already import
LoggerAwareTrait, leading to fatal errors due to duplicate properties
and method definitions. Instead, ActionController implements
LoggerAwareInterface and provides its own `setLogger()` method,
ensuring full backwards compatibility for extensions.

Controllers that still use LoggerAwareTrait continue to work
unchanged. Using the trait in such controllers is not deprecated but
now superfluous, as ActionController provides the logger automatically.

Review

  • Code review CR +1
    • Garvin Hicking +1
    • Guido Schmechel +1
    • Torben Hansen +1
    • Stefan Froemken +1
  • Verified V -1
    • Garvin Hicking +1
    • Guido Schmechel +1
    • Alexander Schnitzler -1
    • Torben Hansen +1
    • core-ci +1 CI

Issues 1

Files 6

Review log 1520

  1. Lina Wolf uploaded patch set 1 12/02/25, 15:52

  2. Lina Wolf updated the commit message in patch set 2 12/02/25, 15:54

  3. Lina Wolf rebased onto patch set 3 12/02/25, 15:56

  4. core-ci voted on patch set 1 V -1 12/02/25, 16:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91454

  5. core-ci voted on patch set 2 V -1 12/02/25, 16:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91455

  6. core-ci voted on patch set 3 V -1 12/02/25, 16:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91456

  7. Lina Wolf uploaded patch set 4 V -1 12/02/25, 16:08

  8. core-ci voted on patch set 4 V +1 12/02/25, 16:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91458

  9. Simon Schaufelberger voted on patch set 4 CR +1 12/03/25, 07:56

  10. Lina Wolf rebased onto patch set 5 CR +1 V +1 12/03/25, 08:05

  11. core-ci voted on patch set 5 V +1 12/03/25, 08:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91506

  12. Stefan Froemken voted on patch set 5 CR +1 12/10/25, 08:28

  13. Guido Schmechel voted on patch set 5 CR +1 V +1 12/12/25, 18:50

  14. Torben Hansen voted on patch set 5 CR +1 V +1 12/13/25, 07:50

  15. Garvin Hicking voted on patch set 5 CR +1 V +1 12/13/25, 13:03

  16. Christian Kuhn commented on patch set 5 CR -1 12/13/25, 15:10

    why? the abstract does not need a logger, many controllers don't need one either. controllers that need one can just use __construct() to get one injected.
  17. Lina Wolf commented on patch set 5 12/14/25, 03:10

    Reply

    We actually do need the logger for https://review.typo3.org/c/Packages/TYPO3.CMS/+/89080/15, where we need it in the ActionController. The idea for this pr came from trying to remove the complexicty and discussion topic from #89080, which is based on this change. Constructor Injection is not feasible in all context, it expecially gets complicated when Controllers or Abstract Controllers provided by extensions are extended.
  18. Christian Kuhn wrote 06/18/26, 23:07

    Removed reviewer Christian Kuhn with the following votes: * Code-Review-1 by Christian Kuhn
  19. Alexander Schnitzler commented on patch set 5 V -1 10/18/26, 14:41

    Reply Unresolved

    -1, sorry, Christian is right, this breaks existing controllers. ActionController now declares protected ?LoggerInterface $logger. Every controller that declares its own $logger redeclares that property, and PHP only accepts the same type, a visibility not stricter than protected, and no readonly. The common pattern, constructor injection with property promotion, fails with a fatal error as soon as the class is loaded (checked against patch set 5): - private readonly LoggerInterface $logger (promoted): "Cannot redeclare non-readonly property ActionController::$logger as readonly" - protected readonly LoggerInterface $logger (promoted): same fatal - private LoggerInterface $logger (promoted): "Access level to ...::$logger must be protected (as in class ActionController) or weaker" - protected LoggerInterface $logger (not nullable): "Type of ...::$logger must be ?Psr\Log\LoggerInterface (as in class ActionController)" - use LoggerAwareTrait: works, because the trait happens to declare exactly the same property One such controller is enough to make the DI container of its extension fail to build. So the "full backwards compatibility" in the commit message only holds for controllers using LoggerAwareTrait. Controllers can already get a logger without boilerplate in the base class: constructor injection, an inject*() method, or LoggerAwareInterface/LoggerAwareTrait (all wired by the container). If ActionController itself needs to log (as for change 89080), a private property set by an inject method with a unique name would avoid the collisions, e.g. private ?LoggerInterface $actionControllerLogger = null; public function injectActionControllerLogger(LoggerInterface $logger): void { $this->actionControllerLogger = $logger; } A private property is not inherited, so subclasses stay free to declare their own $logger in any form.
  20. Lina Wolf abandoned the change 10/25/26, 17:38