Review main Merged

69495[FEATURE] Auto-detect event types on listener services

crell CR +2 V +2 Normal +155 −53 updated 06/17/21, 19:25

Commit message

The 'event:' tag in Services.yaml can be omitted since,
the wiring is done automatically by reflecting the
target method at compile-time.

Review

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

Issues 1

Files 15

Review log 2436

Show 611 earlier messages
  1. crell uploaded patch set 1 06/14/21, 21:24

  2. core-ci voted on patch set 1 V -1 06/14/21, 21:27 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12433

  3. crell uploaded patch set 2 06/14/21, 21:35

  4. core-ci voted on patch set 2 V -1 06/14/21, 21:43 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12434

  5. crell uploaded patch set 3 06/14/21, 21:51

  6. core-ci voted on patch set 3 V -1 06/14/21, 22:00 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12435

  7. crell uploaded patch set 4 06/15/21, 14:51

  8. core-ci voted on patch set 4 V -1 06/15/21, 14:59 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12451

  9. crell uploaded patch set 5 06/15/21, 15:57

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

  11. Christian Kuhn uploaded patch set 6 06/16/21, 19:44

  1. Christian Kuhn commented on patch set 6 CR -1 06/16/21, 19:46

    Fine with me in general (didn't test yet, but that should be easy). One thing left: All core-registered listeners should be adapted. A helper: find . -name \*Services.yaml* -print -exec grep event {} \; And please verify all listeners actually have the correct signature along the way.
  2. core-ci voted on patch set 6 V +1 06/16/21, 19:55 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12507

  3. Benjamin Franzke wrote 06/16/21, 20:15

    Topic set to di
  4. crell commented on patch set 6 06/16/21, 20:54

    Reply

    Cool. I wanted to verify everything else was good before I went through and converted everything, so that's the next proper step.
  5. Benjamin Franzke commented on patch set 6 CR -1 06/16/21, 20:56

    Hey, I don't really like that the descriptiveness of the configuration decreases, but the removed redundancy and static analysis kinda outweighs this. So fine with me in general, so just some remarks..

    ListenerProviderPass.php:61

    This is an invalid state, so we should either don't check at all, or throw a RuntimeException instead of a silent continue. Goes inline with code in vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php::getReflectionMethod which throws an exception as well.

    ListenerProviderPass.php:64

    I would consider reflection as autowiring, therefore we should only do this if the Definition has `autowire: true` (which is what we usually define in _defaults). So additionally check for $service->isAutowired().

    ListenerProviderPass.php:108

    Now that we autodetect the type (with the intention to decrease programming errors, right?) we should also check if the method a) is available and b) public, So similar as done in vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php::getReflectionMethod Wonder if we should simply extend from AbstractRecursivePass (without using it's process() method) in order to use the existing getReflectionMethod() method from symfony/dependnecy-injection, which does most things we "want".
  6. crell commented on patch set 6 06/16/21, 22:41

    Reply

    Done

    ListenerProviderPass.php:61 Reply

    This was left over from trying to get PHPStan to not whine about passing a string instead of a class-string to reflection. Will remove.

    ListenerProviderPass.php:64 Reply

    I am not convinced of this, personally, but if that's generally defaulted to on anyway I am not going to make a fuss about it. :-)

    ListenerProviderPass.php:108 Reply

    I looked at that method, and it isn't quite usable as is. It's too tied into the recursion logic. So I stole^W borrowed the code and tweaked it as needed. I also filed an issue with Symfony to maybe split them off to be more useful later (https://github.com/symfony/symfony/issues/41726), though now that I've done it I don't know if reusable versions would actually be reusable. I also did some other cleanup and refactoring while I was at it, so I think the code is cleaner now, with more error bail outs.
  7. crell uploaded patch set 7 06/16/21, 22:42

  8. core-ci voted on patch set 7 V -1 06/16/21, 22:44 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12518

  9. crell uploaded patch set 8 06/17/21, 14:14

  10. core-ci voted on patch set 8 V -1 06/17/21, 14:17 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12543

  11. crell uploaded patch set 9 06/17/21, 14:26

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

  13. Christian Kuhn uploaded patch set 10 06/17/21, 16:49

  14. Christian Kuhn uploaded patch set 11 06/17/21, 16:53

  15. Christian Kuhn voted on patch set 11 V +1 CR +1 06/17/21, 16:55

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

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

  18. Benjamin Franzke commented on patch set 11 V -1 CR -1 06/17/21, 19:11

    Comparing the DependencyInjection cache with and without this patch applied reveals that the we got one event-changed (because a typo in RecordHistoryRollbackEventsListener.php in this patch): diff /tmp/DependencyInjectionContainer_d6e10681ce15b967e133872f13c191a17cf393f0.php typo3temp/var/cache/code/di/DependencyInjectionContainer_d6e10681ce15b967e133872f13c191a17cf393f0.php 5066,5067c5066,5067 < $a->addListener('TYPO3\\CMS\\Backend\\History\\Event\\BeforeHistoryRollbackStartEvent', 'TYPO3\\CMS\\Redirects\\EventListener\\RecordHistoryRollbackEventsListener', 'beforeHistoryRollbackStartEvent'); < $a->addListener('TYPO3\\CMS\\Backend\\History\\Event\\AfterHistoryRollbackFinishedEvent', 'TYPO3\\CMS\\Redirects\\EventListener\\RecordHistoryRollbackEventsListener', 'afterHistoryRollbackFinishedEvent'); --- > $a->addListener('TYPO3\\CMS\\Backend\\History\\Event\\AfterHistoryRollbackFinishedEvent', 'TYPO3\\CMS\\Redirects\\EventListener\\RecordHistoryRollbackEventsListener', 'beforeHistoryRollbackStartEvent'); > $a->addListener('TYPO3\\CMS\\Backend\\History\\Event\\BeforeHistoryRollbackStartEvent', 'TYPO3\\CMS\\Redirects\\EventListener\\RecordHistoryRollbackEventsListener', 'afterHistoryRollbackFinishedEvent'); Will fix.

    RecordHistoryRollbackEventsListener.php:26

    Event types are swapped in here and the following method.
  19. Benjamin Franzke uploaded patch set 12 06/17/21, 19:13

  20. Benjamin Franzke commented on patch set 12 06/17/21, 19:13

    RecordHistoryRollbackEventsListener.php:26 Reply

    Done
  21. Benjamin Franzke commented on patch set 12 CR +1 06/17/21, 19:25

    ListenerProviderPass.php:64 Reply

    Thanks.

    ListenerProviderPass.php:108 Reply

    Thanks, yea, good approach. Copying that is good as well, for now…
  22. Christian Kuhn voted on patch set 12 V +1 CR +1 06/17/21, 19:25

  23. core-ci voted on patch set 12 V +1 06/17/21, 19:25 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12561

  24. Benjamin Franzke voted on patch set 12 V +2 CR +2 06/17/21, 19:25

  25. Benjamin Franzke merged patch set 13 06/17/21, 19:25