Review main Merged

72005[BUGFIX] Use ClassSchema to properly detect DomainObject properties

Alexander Schnitzler CR +2 V +2 Normal +134 −80 updated 08/22/22, 14:57

Commit message

To gather information about properties of domain objects, extbase
used method DomainObjectInterface::_getProperties() which internally
used get_object_vars() which does not return uninitialized properties.

This leads to the inability to use such uninitialized properties
in models. Hence, those properties are not reconstituted at all
when converting an object instance from a database row, eventually
leading to fatal errors.

To mitigate this issue, extbase does now use the existing information
about classes gathered via ClassSchema which gathers information via
reflection (anyway).

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Markus Klein +1
    • Nikita Hovratov +1
    • Stefan Froemken +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Benni Mack +2
    • Markus Klein +1
    • Stefan Froemken +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 8

Review log 5070

Show 2945 earlier messages
  1. Alexander Schnitzler uploaded patch set 1 10/29/21, 15:33

  2. Alexander Schnitzler wrote 10/29/21, 15:33

    Topic set to extbase
  3. Alexander Schnitzler uploaded patch set 2 10/29/21, 15:46

  4. core-ci voted on patch set 2 V -1 10/29/21, 16:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18659

  5. Alexander Schnitzler uploaded patch set 3 10/29/21, 16:08

  6. core-ci voted on patch set 3 V -1 10/29/21, 16:23 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18660

  7. Alexander Schnitzler uploaded patch set 4 10/29/21, 16:52

  8. core-ci voted on patch set 4 V -1 10/29/21, 17:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18661

  9. core-ci voted on patch set 1 V -1 10/29/21, 17:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18658

  10. Alexander Schnitzler uploaded patch set 5 10/30/21, 09:06

  11. core-ci voted on patch set 5 V +1 10/30/21, 09:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18664

  12. Alexander Schnitzler commented on patch set 5 10/30/21, 09:27

    This change is ready for review.
  13. Alexander Schnitzler updated the commit message in patch set 6 10/30/21, 10:52

  14. core-ci voted on patch set 6 V +1 10/30/21, 11:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18666

  15. Anja Leichsenring updated the commit message in patch set 7 11/04/21, 11:40

  16. core-ci voted on patch set 7 V +1 11/04/21, 11:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18871

  17. Benni Mack updated the commit message in patch set 8 11/18/21, 10:45

  18. core-ci voted on patch set 8 V +1 11/18/21, 11:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19460

  19. Benni Mack wrote 11/29/21, 10:15

    Change destination moved from master to main
  20. Benni Mack updated the commit message in patch set 9 11/29/21, 14:03

  21. core-ci voted on patch set 9 V +1 11/29/21, 16:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20080

  22. Christian Kuhn commented on patch set 9 12/06/21, 16:33

  23. Stefan Bürk commented on patch set 9 12/07/21, 05:41

    ^ The one Christian pointed has gone, but now the same author added another try, now with Reflection approach: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72537
  24. Alexander Schnitzler commented on patch set 9 12/07/21, 06:38

    Reply

    Let's focus on this one. With this patch we move the resolval of reflection data to where it belongs, the ClassSchema. The goal is to be able to remove getObjectProperties from the AbstractDomainObject and to have models without the need to extend AbstractDomainObject at all some day.
  25. Stefan Froemken commented on patch set 9 V +1 CR +1 12/13/21, 11:25

    Works good until now. Before this patch I get a lot of "Typed property JWeiland\Events2\Domain\Model\Day::$event must not be accessed before initialization" messages, but with this patch the errors are gone. Good work.
  26. Stefan Froemken commented on patch set 9 V -1 CR -1 12/14/21, 08:07

    DataMapper.php:248

    This part can result NULL. F.e. for starttime or endtime columns

    DataMapper.php:270

    As $this->mapDateTime() can return NULL this property will not be set. As it was not set, it will not be initialized.
  27. Stefan Froemken uploaded patch set 10 12/14/21, 08:22

  28. core-ci voted on patch set 10 V -1 12/14/21, 08:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21063

  29. Stefan Froemken commented on patch set 10 CR -1 12/14/21, 08:31

    Sorry...wrong base branch. I will deliver a new patch
  30. Stefan Froemken uploaded patch set 11 12/14/21, 08:47

  31. Stefan Froemken commented on patch set 11 12/14/21, 08:49

    I have added a test to show the problem with uninitialized ?\DateTime properties
  32. Stefan Froemken uploaded patch set 12 12/14/21, 08:51

  33. core-ci voted on patch set 11 V -1 12/14/21, 09:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21066

  34. core-ci voted on patch set 12 V -1 12/14/21, 09:06 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21067

  35. Stefan Froemken uploaded patch set 13 12/14/21, 12:25

  36. core-ci voted on patch set 13 V -1 12/14/21, 12:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21076

  37. Stefan Froemken uploaded patch set 14 12/14/21, 12:30

  38. core-ci voted on patch set 14 V +1 12/14/21, 12:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21077

  39. Stefan Froemken uploaded patch set 15 12/14/21, 13:14

  40. core-ci voted on patch set 15 V +1 12/14/21, 13:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21079

  41. Stefan Froemken uploaded patch set 16 12/14/21, 13:46

  42. Markus Kugler commented on patch set 16 CR +1 12/14/21, 14:04

    Looks good to me, I like the test for uninitialized properties in DataMapperTest.php
  43. core-ci voted on patch set 16 V +1 12/14/21, 14:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21083

  44. Markus Kugler commented on patch set 16 12/15/21, 06:53

    Reply

    Sorry, didn't check the resolved checkbox. -> New to gerrit.
  45. Stefan Froemken voted on patch set 16 V +1 CR +1 12/23/21, 20:27

  1. Stefan Bürk uploaded patch set 17 01/05/22, 18:12

  2. Stefan Bürk commented on patch set 17 01/05/22, 18:14

    Reply

    Done
  3. core-ci voted on patch set 17 V +1 01/05/22, 18:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/21663

  4. Stefan Froemken commented on patch set 17 01/05/22, 21:20

    Property.php:147

    Why you have removed that? I mean: If you remove that wouldn't it be better to remove const PropertyCharacteristics::ANNOTATED_INJECT and line 248-254 in ClassSchema.php, too?
  5. Stefan Bürk commented on patch set 17 01/05/22, 21:51

    Property.php:147 Reply

    The answer is simple: Solving merge-conflict manually. You are "right", but that was already done with: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72498 Just solving the merge-conflict/rebase on that.
  6. Nikita Hovratov rebased onto patch set 18 05/18/22, 15:59

  7. core-ci voted on patch set 18 V +1 05/18/22, 16:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27306

  8. Nikita Hovratov uploaded patch set 19 05/18/22, 16:27

  9. Nikita Hovratov commented on patch set 19 05/18/22, 16:31

    DataMapper.php:270 Reply

    Done
  10. core-ci voted on patch set 19 V -1 05/18/22, 16:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27308

  11. Nikita Hovratov commented on patch set 19 05/18/22, 16:40

    DataMapper.php:248 Reply

    I guess this is resolved by your patches, too.
  12. Nikita Hovratov uploaded patch set 20 05/18/22, 16:41

  13. Nikita Hovratov voted on patch set 20 CR +1 05/18/22, 16:42

  14. core-ci voted on patch set 20 V +1 05/18/22, 16:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27309

  15. Alexander Schnitzler commented on patch set 20 07/31/22, 12:32

    Hi Folks, what's the hold up here? I have the feeling nobody really knows the status of this patch, hence the lack of reviews, right? Stefan, are all issues, you mentioned, resolved? And to all others: Can you make sure to remove yourself as reviewer or cc if you don't intend to review. No hard feelings here, just want to make sure this patch doesn't look crowded and/or well taken care of if it isn't. Thanks in advance. :) And regarding those that want to participate: Does anyone wants to take the lead or should I push things forward again. I am asking because this patch went through a couple of hands now and I don't know who is responsible.
  16. Simon Schaufelberger commented on patch set 20 V -1 08/02/22, 16:21

    I have a customer project with exactly this issue. I have applied this patch via composer patches but the issue I have now is that properties annotated with an Object and no default value don't work like: protected StaticCountry $country; Since this property is required and can't be null, this is correct. In the initializeObject() method, I assign a default value but somehow this method is not executed at all times because now I get an exception: Typed property Vendor\Extension\Domain\Model\Bla::$country must not be accessed before initialization in AbstractDomainObject: public function _getProperty(string $propertyName) { return $this->{$propertyName}; } @Alex: can you verify?
  17. Simon Schaufelberger commented on patch set 20 08/02/22, 16:48

    Reply

    This error happens when I update an object and persist it.
  18. Simon Schaufelberger commented on patch set 20 V +1 CR +1 08/03/22, 13:03

    I've played with blog_example and it really works.
  19. Simon Schaufelberger commented on patch set 20 08/03/22, 13:05

    Reply

    My problem is that I serialize a model and store it in the user session and when I restore it, it doesn't have all the nested objects initialized. Therefor this patch is valid and I need to fix my code instead.
  20. Markus Klein voted on patch set 20 V +1 CR +1 08/03/22, 17:09

  21. Stefan Froemken commented on patch set 20 V +1 CR +1 08/04/22, 18:25

    Works, but keep in mind: If you work with "protected \DateTime $date;" you should also/have to set this field as required in TCA and validate against NotEmpty in Domain Model. If you also think that this is the expected way to go: Happy merging ;-)
  22. Simon Schaufelberger commented on patch set 20 08/04/22, 23:25

    Reply

    They have nothing to do with each other. This is the responsibility of the developer to take care of this himself.
  23. Benni Mack voted on patch set 20 V +2 CR +2 08/08/22, 12:47

  24. Benni Mack merged patch set 21 08/08/22, 12:47

  25. Oliver Hader commented on patch set 21 08/22/22, 14:57