Review main Merged Breaking

75158[!!!][FEATURE] Add PSR-14 Events for flex form parsing

crell CR +2 V +2 Nightmare +2910 −2953 updated 09/08/22, 11:48

Commit message

Four new PSR-14 Events are added, which allow to fully
control the flex form parsing in an object-oriented
way. They replace the now removed
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][FlexFormTools::class]['flexParsing']
hook.

The new events work similar to the removed hooks. One
noteworthy change however is, that event propagation
of the "Before*" events is immediately stopped as soon
as a listener sets a corresponding value. Previously,
hook implementations had to always return a value,
which means they returned e.g. an empty array to allow
further hooks to be called. This however would now stop
propagation and should therefore be avoided. Listeners
which don't want to set corresponding value should just
"return" without any change to the event object.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Benni Mack +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 38

Show 18 more files

Review log 5275

Show 3550 earlier messages
  1. crell uploaded patch set 1 07/12/22, 19:34

  2. core-ci voted on patch set 1 V -1 07/12/22, 19:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29012

  3. crell uploaded patch set 2 07/12/22, 20:28

  4. core-ci voted on patch set 2 V -1 07/12/22, 20:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29015

  5. crell uploaded patch set 3 07/13/22, 16:57

  6. core-ci voted on patch set 3 V -1 07/13/22, 17:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29078

  7. crell uploaded patch set 4 07/13/22, 20:56

  8. core-ci voted on patch set 4 V -1 07/13/22, 21:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29101

  9. crell uploaded patch set 5 07/13/22, 21:20

  10. crell updated the commit message in patch set 6 07/13/22, 21:20

  11. crell rebased onto patch set 7 07/13/22, 21:24

  12. crell commented on patch set 7 07/13/22, 21:26

    This should be in a reviewable state now. I am unclear what's going on with the Deprecations fails, as that's all code I didn't touch. I suspect there's other design refactoring that could be done to the events by someone with more knowledge of how they're typically used, but this is a fairly 1:1 migration. If there's other changes that should be made while we're at it (since this is a convenient time to do so), please advise.
  13. core-ci voted on patch set 5 V -1 07/13/22, 21:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29102

  14. core-ci voted on patch set 7 V -1 07/13/22, 21:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29104

  15. core-ci voted on patch set 6 V -1 07/13/22, 21:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29103

  16. Benni Mack commented on patch set 7 CR -1 07/14/22, 19:39

    The hook in EXT:form should be removed.
  17. Stefan Bürk rebased onto patch set 8 07/15/22, 00:33

  18. Stefan Bürk commented on patch set 8 CR -1 07/15/22, 00:35

    Reply

    Rebased onto fixed `checkAnnotations` integration test. Re-apply Benni's -1 on it.
    Re-apply Benni's -1 on it.
  19. core-ci voted on patch set 8 V -1 07/15/22, 00:40 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29179

  20. crell commented on patch set 8 07/19/22, 15:36

    Reply

    Grepping through ext:form, I see over a dozen references to different `$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']` parameters. I'd really rather do that separately, as this patch is involved enough as is. Or is there some other hook you're talking about?
  21. crell uploaded patch set 9 07/19/22, 17:23

  22. core-ci voted on patch set 9 V +1 07/19/22, 17:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29362

  23. Oliver Hader commented on patch set 9 07/19/22, 20:37

    FlexParsingGetDataStructureEvent.php:12

    Personally, I dislike these PhpStan specifics... However, if it turns out to be helpful to others, I'd suggest the following: ``` use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools ... /** * @phpstan-import-type FlexFormToolsIdentifier from FlexFormTools */ ``` This way, it is clear, that local type actually belongs to `FlexFormTools`.
  24. Oliver Hader commented on patch set 9 07/19/22, 20:43

    FlexParsingGetDataStructureEvent.php:12 Reply

    Some more clarification. Using local types "local" in the very same file is okay. Using pseudo-types in different files and probably™ across packages and ignoring the existence of namespaces, is creating new "future challenges"...
  25. Oliver Klee commented on patch set 9 07/19/22, 21:07

    FlexParsingGetDataStructureEvent.php:12 Reply

    I agree (both with this point as well as the suggestion).
  26. crell commented on patch set 9 07/19/22, 21:54

    FlexParsingGetDataStructureEvent.php:12 Reply

    I am torn on it, personally. Additionally, I'm no sure if it's safe to keep at all, because in practice both tests and the existing hook code that I'm converting to events in ext:form use entirely different sets of keys, so PHPStan complains. Just throwing them all into the baseline file seems like a bad solution, but it suggests that the identifier struct is insufficiently defined in the first place for the array shape to make sense at all. So it may be better to drop the explicit shape type and define it informally in the comment instead. I'm not sure what the typical usage pattern is right now, so I'm open to suggestions. The options I see are: 1. Roll it back and just make it an informal doc. 2. Keep it as is, with the more precise name, and add more exceptions to the baseline file. 3. Same as 2, but also update the tests at least to mock the formal structure better. (I've not tried to see how much work this might be.)
  27. crell uploaded patch set 10 07/19/22, 21:56

  28. core-ci voted on patch set 10 V -1 07/19/22, 22:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29368

  29. Oliver Hader commented on patch set 10 07/20/22, 09:06

    FlexParsingGetDataStructureEvent.php:12 Reply

    or "4. Try harder" - now that we are one the way of enforcing strict types everywhere, it really would be a pity to stop here when things are getting interesting! From a OOP-POV there would be local & extended variant of `Identifier` in `ext:form`. From a JSON-Schema-POV it would be a dynamic property.
  30. Stefan Bürk commented on patch set 10 07/20/22, 12:51

    FlexParsingGetDataStructureEvent.php:12 Reply

    Why not introducing a small FlexFormIdentifier class with the 4 properties. And at least use it for the event, as a start. Or flexform tools internal - and avoiding to distribute phpstan "array" identifier type's through the core ?
  31. crell commented on patch set 10 07/20/22, 14:09

    FlexParsingGetDataStructureEvent.php:12 Reply

    I considered just making the identifier a proper class, and all else equal I would vastly prefer that. However, I don't understand the existing usages well enough to say if that would break things. The only live implementation of the hooks in core, I think, is the one in ext:form that I just finished converting, and it already is checking for a $identifier['ext-form-persistenceIdentifier'] key. The existing docs talk about a uid key as something that... maybe should be used, but shouldn't. (Honestly, it's a bit confusing to me.) I could handle converting the tests, but I don't know what to do about existing implementations like that. If we can figure out an approach that doesn't involve crippling the functionality, I am 100% in favor of switching to an object. Oliver: The Identifier struct/class/whatever is created in FlexFormTools, so we wouldn't be able to have an ext:form specific version of it. We *could* potentially do a double-property class, with explicit settable properties and ArrayAccess for "other stuff". I don't know if I like that, but it's an option.
  32. Oliver Klee wrote 07/21/22, 10:36

    Removed cc Oliver Klee.
  33. crell uploaded patch set 11 08/05/22, 16:18

  34. crell commented on patch set 10 08/05/22, 16:19

    FlexParsingGetDataStructureEvent.php:12 Reply

    Christian Kuhn reports that the structure is too fuzzy and inconsistent to bother trying to formalize, so I backed out the phpstan type and just documented the likely keys.
  35. core-ci voted on patch set 11 V -1 08/05/22, 18:23 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29833

  36. crell uploaded patch set 12 08/05/22, 21:25

  37. core-ci voted on patch set 12 V +1 08/05/22, 21:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29865

  38. Chris Müller commented on patch set 12 CR -1 08/08/22, 17:26

    I would prefer to name the FlexParsing...Event better FlexFormParsing...Event to reflect that they can be used to manipulate flexforms. For previous hooks this was clear as FlexForm was part of the array structure when registering them.

    Feature-97449-PSR-14EventsForControllingFlexParsing.rst:39

    As the IconFactory is not used in this example it should be not injected.
  39. crell uploaded patch set 13 08/09/22, 15:08

  40. crell commented on patch set 12 08/09/22, 15:08

    Feature-97449-PSR-14EventsForControllingFlexParsing.rst:39 Reply

    Done
  41. core-ci voted on patch set 13 V +1 08/09/22, 15:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29976

  42. crell uploaded patch set 14 08/16/22, 18:22

  43. core-ci voted on patch set 14 V +1 08/16/22, 18:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30209

  44. Simon Schaufelberger uploaded patch set 15 08/16/22, 20:08

  45. Simon Schaufelberger commented on patch set 15 08/16/22, 20:11

    FlexFormToolsTest.php:53

    To make Stefan a lot less angry, please use mocks as he is trying to get rid of prophecy in the core or talk to him about it.
  46. core-ci voted on patch set 15 V +1 08/16/22, 20:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30210

  47. Simon Schaufelberger commented on patch set 15 08/16/22, 20:16

    FlexFormToolsTest.php:53 Reply

    let me rephrase it, he is not angry but to "make him really happy"...
  48. crell commented on patch set 15 08/17/22, 17:20

    FlexFormToolsTest.php:53 Reply

    I'd normally never use Prophecy myself, either. But this is just splitting up existing tests so that the event can be tested, not adding any new Prophecy usage. Refactoring to remove that is a separate task.
  49. Stefan Bürk commented on patch set 15 08/24/22, 21:48

    FlexFormToolsTest.php:53 Reply

    First - it is not about make me "happy" or "angry". The pure fact is, that prophecy seems to be dead. And it is more a core decision to remove prohecy usage from core and with that the dependency (directly and indirectly at some point then). Beside that this is already a bigger task itself, and this patch has been gone through the one or other round and Larry has bleeded to tackle all that test adjustments on existing prophecies to get tests green I would have mentationed it as a "infor for the future" and would say to take this here. And Larry is known to favoriousing not using prophecy or other mock libraries - which now got backed by the need because of the stand with prophecy.
  50. Stefan Bürk uploaded patch set 16 08/24/22, 21:49

  1. Stefan Bürk commented on patch set 16 08/24/22, 21:49

    Rebased because of merge conflict.
  2. core-ci voted on patch set 16 V +1 08/24/22, 21:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30428

  3. Simon Schaufelberger wrote 08/24/22, 22:10

    Removed cc Simon Schaufelberger.
  4. Georg Ringer commented on patch set 16 08/25/22, 06:48

    FlexFormParsingGetDataStructureEvent.php:3

    doc "This file is part of the TYPO3 CMS project." missing
  5. Georg Ringer voted on patch set 16 CR -1 08/25/22, 06:48

  6. Stefan Bürk commented on patch set 16 08/25/22, 08:37

    FlexFormParsingGetDataStructureEvent.php:3 Reply

    time to get the file header check/fix back - will finish a patch for that later. => https://review.typo3.org/c/Packages/TYPO3.CMS/+/75549

    MockEventDispatcher.php:15

    missing space for lines - time to file header check back
  7. Stefan Bürk rebased onto patch set 17 08/26/22, 17:20

  8. core-ci voted on patch set 17 V -1 08/26/22, 17:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30471

  9. Stefan Bürk uploaded patch set 18 08/27/22, 12:55

  10. core-ci voted on patch set 18 V +1 08/27/22, 13:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30489

  11. Stefan Bürk uploaded patch set 19 08/27/22, 13:12

  12. core-ci voted on patch set 19 V +1 08/27/22, 13:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30490

  13. crell commented on patch set 19 08/29/22, 14:48

    FlexFormParsingGetDataStructureEvent.php:3 Reply

    Done

    MockEventDispatcher.php:15 Reply

    Done
  14. Stefan Bürk rebased onto patch set 20 09/06/22, 15:29

  15. core-ci voted on patch set 20 V +1 09/06/22, 15:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30653

  16. Georg Ringer rebased onto patch set 21 09/06/22, 20:04

  17. core-ci voted on patch set 21 V +1 09/06/22, 20:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30684

  18. Oli Bartsch uploaded patch set 22 09/08/22, 09:30

  19. core-ci voted on patch set 22 V -1 09/08/22, 09:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30799

  20. Oli Bartsch uploaded patch set 23 09/08/22, 09:48

  21. core-ci voted on patch set 23 V +1 09/08/22, 09:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/30801

  22. Oli Bartsch voted on patch set 23 V +1 CR +1 09/08/22, 10:01

  23. Benni Mack voted on patch set 23 V +1 CR +1 09/08/22, 10:18

  24. Oli Bartsch voted on patch set 23 V +2 CR +2 09/08/22, 11:48

  25. Oli Bartsch merged patch set 24 09/08/22, 11:48