Review main Merged

78051[TASK] Let DataMapper::createEmptyObject() use doctrine/instantiator

Alexander Schnitzler CR +2 V +2 Hard +336 −96 updated 03/29/23, 09:32

Commit message

During the removal of the ObjectManager (Extbase), the way the
DataMapper instantiates entities when thawing objects, i.e.
fetching a database row and transform it back into an entity
object, changed. doctrine/instantiator had been used to create
empty objects, i.e. creating objects without calling their
constructor. Now, entities with constructors cannot be thawed
any longer. To bring back this way of working (which existed
for as long as Extbase itself does), doctrine/instantiator is
brought back and used.

> composer req doctrine/instantiator:^2.0

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Daniel Goerz +1
    • Oliver Klee +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Daniel Goerz +1
    • Oliver Klee +1
    • core-ci +1 CI

Issues 2

Files 10

Review log 4660

Show 2635 earlier messages
  1. Alexander Schnitzler uploaded patch set 1 03/08/23, 08:22

  2. Alexander Schnitzler marked it work in progress 03/08/23, 08:22

  3. Alexander Schnitzler wrote 03/08/23, 08:23

    Topic set to extbase
  4. core-ci voted on patch set 1 V +1 03/08/23, 08:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38644

  5. Alexander Schnitzler commented on patch set 1 03/08/23, 08:42

    DataMapper.php:182

    Hey, with https://review.typo3.org/c/Packages/TYPO3.CMS/+/72469, we removed the ObjectManager and along with it a couple of features/functionalities that partly have a replacement. Extbase had it's own class override mechanic besides XClassing. That vanished and I agree. XClassing is the way to go. No issues here. Extbase also created empty (constructed without calling the constructor) objects for years. This was in line with `doctrine/orm` and other ORM's that allow users to use POPOs. Some ORM's make the user extend a certain class or implement an interface but aside from that people can use their entities like regular objects including using the constructor. With the removal of the `ObjectManager`, this possibility also vanished, leaving people with broken code if they used entities with constructors to create entities (non-persisted) with a valid initial state. I am thinking a lot about this whole topic. It's not just the constructor. There is the overall question of how a framework uses user land code features. Should a framework dictate the user to create dumb getters/setters because itself needs those? Does it prevent users from using getters/setters with additional logic because the framework calls those in situations those are not supposed to be called in because they are domain specific implementations? I think a framework should keep its hands away as much as possible. Yes, that requires magic on the framework side and often it's not the most sustainable solution but it's a clear separation of responsibility. Via `AbstractDomainObject`, extbase is capable of manipulating the entity state without interfering with getters/setters. It doesn't always stick to it (`PersistentObjectConverter` uses setters as well) but that's my goal. I don't want the framework to call possibly non-existing methods on entities that also might have a different intention than the framework expects. Please let's have a chat here and have this bigger picture in mind.
  6. Alexander Schnitzler uploaded patch set 2 V +1 03/08/23, 09:09

  7. core-ci voted on patch set 2 V -1 03/08/23, 09:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38647

  8. Alexander Schnitzler uploaded patch set 3 V -1 03/17/23, 14:38

  9. Alexander Schnitzler updated the commit message in patch set 4 03/17/23, 14:44

  10. Alexander Schnitzler marked it ready for review 03/17/23, 14:44

  11. Alexander Schnitzler commented on patch set 4 03/17/23, 14:45

    I'd personally consider this a severe bug and also backport to 11. I had quite a lot of projects with failing entities that needed workarounds. wdyt?
  12. core-ci voted on patch set 3 V -1 03/17/23, 14:49 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39137

  13. Alexander Schnitzler uploaded patch set 5 03/17/23, 14:59

  14. core-ci voted on patch set 4 V -1 03/17/23, 15:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39138

  15. core-ci voted on patch set 5 V +1 03/17/23, 15:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39139

  16. Alexander Schnitzler uploaded patch set 6 V +1 03/21/23, 15:48

  17. Alexander Schnitzler commented on patch set 6 03/21/23, 15:49

    PS6 is just a manual rebase.
  18. core-ci voted on patch set 6 V +1 03/21/23, 15:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39325

  19. Alexander Schnitzler uploaded patch set 7 V +1 03/21/23, 18:50

  20. Alexander Schnitzler commented on patch set 7 03/21/23, 18:51

    Reply

    Done

    DataMapper.php:182 Reply

    Done
  21. Alexander Schnitzler updated the commit message in patch set 8 03/21/23, 18:51

  22. Alexander Schnitzler commented on patch set 8 03/21/23, 19:04

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:155

    Missing: A word on private properties, that are not able to be used because `AbstractDomainObject::_setProperty()` cannot access the private property of sub classes. Hence, all used properties in these examples need to be protected.
  23. core-ci voted on patch set 8 V -1 03/21/23, 19:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39335

  24. core-ci voted on patch set 7 V -1 03/21/23, 19:23 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39334

  25. Oliver Klee commented on patch set 8 03/21/23, 21:11

    According to PHPStan, we'll need to adapt/add a type annotation in a functional test: https://git.typo3.org/typo3/CI/cms/-/jobs/2089869
  26. Alexander Schnitzler commented on patch set 8 03/22/23, 07:04

    Reply

    Yep, you can already fix that if you like. With my limited time I currently focus on the rest file. Will also mark this patch WIP again for a while.
  27. Alexander Schnitzler marked it work in progress 03/22/23, 07:04

  28. Alexander Schnitzler commented on patch set 8 03/22/23, 07:11

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:47

    Update examples: Use constrcutor property promotion.

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:155

    One more thing: I think the DataMapper does infer property types from getters (if available). I know for a fact, that the following does not work: class with string property (csv value in db), array return type for the getter (getter does an explode an the csv value). DataMapper then cannot map the db value on the object because array is used as target type and DataMapper does not support arrays. This needs to be fixed btw.

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:155

    We should also add a word on non-working DI in models. It's intentional and will never be supported. People find find ways around it anyway.
  29. Alexander Schnitzler uploaded patch set 9 V -1 03/22/23, 10:42

  30. Alexander Schnitzler commented on patch set 9 03/22/23, 10:43

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:47 Reply

    Done

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:155 Reply

    This does not happen with the DataMapper, but with the PropertyMapper only. Specifically the ObjectConverter. So, this is irrelevant.

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:155 Reply

    Done
  31. Alexander Schnitzler commented on patch set 9 03/22/23, 10:43

    Reply

    Done

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:155 Reply

    Done
  32. core-ci voted on patch set 9 V +1 03/22/23, 10:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39369

  33. Alexander Schnitzler commented on patch set 9 03/22/23, 11:22

    This change is ready for review.
  34. Chris Müller commented on patch set 9 03/22/23, 13:43

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:44

    For $title constructor property promotion is used, so this line should be removed.
  35. Christian Kuhn uploaded patch set 10 V +1 03/29/23, 05:27

  1. Christian Kuhn commented on patch set 10 03/29/23, 05:27

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:44 Reply

    Done
  2. core-ci voted on patch set 10 V +1 03/29/23, 05:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39797

  3. Christian Kuhn commented on patch set 10 03/29/23, 05:38

    alexander and me had a chat on this - it was me who removed doctrine/instantiator together with the removal of the object manager with/in v11 ... we agree the patch is the way to go, and decided to come up with the .rst file to define how extbase should behave in this area once and for all.

    Important-100207-LetDataMappercreateEmptyObjectUseDoctrineinstantiator.rst:17

    great explanation! many thanks!
  4. Christian Kuhn commented on patch set 10 03/29/23, 05:39

    DataMapper.php:177

    keep protected
  5. Christian Kuhn commented on patch set 10 03/29/23, 05:43

    DataMapper.php:177 Reply

    Done
  6. Christian Kuhn uploaded patch set 11 V +1 03/29/23, 06:58

  7. Christian Kuhn uploaded patch set 12 03/29/23, 07:12

  8. core-ci voted on patch set 11 V -1 03/29/23, 07:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39799

  9. core-ci voted on patch set 12 V +1 03/29/23, 07:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39801

  10. Christian Kuhn voted on patch set 12 V +1 CR +1 03/29/23, 07:31

  11. Benni Mack commented on patch set 12 CR -1 03/29/23, 07:32

    Changelog file should go into 12.4
  12. Christian Kuhn commented on patch set 12 V 0 CR 0 03/29/23, 08:31

    Reply

    true. will do.
  13. Christian Kuhn uploaded patch set 13 CR -1 V +1 03/29/23, 08:33

  14. core-ci voted on patch set 13 V +1 03/29/23, 08:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39808

  15. Benni Mack voted on patch set 13 V +1 CR +1 03/29/23, 08:50

  16. Christian Kuhn voted on patch set 13 V +1 CR +1 03/29/23, 08:51

  17. Oliver Klee voted on patch set 13 V +1 CR +1 03/29/23, 08:53

  18. Daniel Goerz commented on patch set 13 CR -1 03/29/23, 09:02

    I'll go over the RST real quick
  19. Daniel Goerz uploaded patch set 14 CR +1 V +1 03/29/23, 09:17

  20. Daniel Goerz voted on patch set 14 V +1 CR +1 03/29/23, 09:17

  21. Christian Kuhn voted on patch set 14 V +1 CR +1 03/29/23, 09:23

  22. core-ci voted on patch set 14 V +1 03/29/23, 09:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39811

  23. Oliver Klee voted on patch set 14 V +1 CR +1 03/29/23, 09:30

  24. Christian Kuhn voted on patch set 14 V +2 CR +2 03/29/23, 09:32

  25. Christian Kuhn merged patch set 15 03/29/23, 09:32