Review main Merged

58925[FEATURE] Add method LazyLoadingProxy::getUid()

Stefan Neufeind CR +2 V +2 Easy +29 −0 updated 10/23/19, 08:54

Commit message

Adding method getUid() to the LazyLoadingProxy class allows for
fetching the uid of proxied objects without fetching the whole
object data from the database first.

This can be used for quick and easy comparisons of objects while
keeping the proxy intact.

Review

  • Code review CR +2 Done
    • Alexander Schnitzler +2
    • Daniel Goerz +1
    • Oliver Klee +1
  • Verified V +2 Done
    • Alexander Schnitzler +2
    • Daniel Goerz +1
    • TYPO3com +1 CI

Issues 1

Files 2

Review log 2428

Show 23 earlier messages
  1. Stefan Neufeind uploaded patch set 1 11/21/18, 18:04

  2. Stefan Neufeind commented on patch set 1 11/21/18, 18:05

    Thanks to Claus for the idea.
  3. TYPO3com voted on patch set 1 V +1 11/21/18, 18:14 Completed build in 10m 08s on Wed, 21 Nov, 07:14 PM Test Summary: 48484 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-30232

  1. Mathias Brodala commented on patch set 1 CR -1 11/22/18, 08:17

    Since this is a feature, a RST must be added.
  2. Oliver Klee commented on patch set 1 11/22/18, 08:30

    A test would also be good.
  3. Stefan Neufeind commented on patch set 2 03/06/19, 07:49

    Published edit on patch set 1.
  4. Stefan Neufeind commented on patch set 2 03/06/19, 07:50

    RST added. Somebody got an idea for a proper testcase?
  5. TYPO3com voted on patch set 2 V +1 03/06/19, 08:00 Completed build in 10m 24s on Wed, 6 Mar, 09:00 AM Test Summary: 46812 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-32545

  6. Mathias Brodala commented on patch set 2 03/06/19, 08:14

    A blackbox functional test could use an arbitrary UID to construct the LazyLoadingProxy. If the change works as intended, you should be able to simply get that UID from the proxy without errors. If you try to access a different property, you should get an error or at least empty result since the referenced DB row does not exist. However, this also shows a shortcoming of this change: you cannot know if the UID is valid unless you load the full object ...

    LazyLoadingProxy.php:129 Unresolved

    Since this is new code we should add a real return type hint here.
  7. Alexander Schnitzler commented on patch set 2 03/19/19, 10:21

    LazyLoadingProxy.php:131

    I see one problem here. If we assume that the fieldValue always holds the uid which is an integer, then we could also force fieldValue to be of type int. Also, we could rename fieldValue to uid. As this is not the case, I currently wonder if there is any case where fieldValue is not the uid of a record but anything else. If it's not the case, I'd really love to rename the field, add proper type hints and then implement the getter. wdyt?
  8. Benni Mack commented on patch set 2 03/21/19, 11:07

    LazyLoadingProxy.php:131 Reply

    hmm, this is one of these cases, which I think could cause side-effects (you never know how people use Extbase actually). If we go "all in" and clean this up the right way (which I'm in favor of), let's add it to master only then.
  9. Alexander Schnitzler commented on patch set 2 03/21/19, 16:20

    LazyLoadingProxy.php:131 Reply

    Well, I'd say, either we know how people use Extbase and then adjust the code accordingly or we don't know and then we leave things as is. The thing is: If we want this patch in which assumes that fieldValue always is an integer uid, then we are safe to type hint here. If not, we probably merge a bug. Because then the comparison of objects based on a uid that is none, fails. For the current persistence I think it's safe to assume that we only deal with integer uid's. Don't you think?
  10. Alexander Schnitzler wrote 03/21/19, 18:52

    Topic set to extbase
  11. Stefan Froemken commented on patch set 2 06/05/19, 11:35

    LazyLoadingProxy.php:131 Reply

    Do you know how ValueObjects are handled? Do they have fieldValue filled correctly?
  12. Alexander Schnitzler commented on patch set 2 06/05/19, 18:17

    LazyLoadingProxy.php:131 Reply Unresolved

    Having looked at the code I am pretty sure that value objects are handled the same like entities. A LazyLoadingProxy is only created for references and the only way we do reference records is by uid. That's also the case for value objects. The DataMapper then uses said uid (well, the foreign key to be precise) as fieldValue. You can follow the path from \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::mapObjectToClassProperty on.
  13. Alexander Schnitzler rebased onto patch set 3 06/29/19, 08:53

  14. TYPO3com voted on patch set 3 V +1 06/29/19, 09:02 Completed build in 09m 35s on Sat, 29 Jun, 11:02 AM Test Summary: 46832 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34633

  15. Alexander Schnitzler uploaded patch set 4 06/29/19, 09:18

  16. TYPO3com voted on patch set 4 V +1 06/29/19, 09:28 Completed build in 10m 15s on Sat, 29 Jun, 11:28 AM Test Summary: 46830 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34634

  17. Alexander Schnitzler commented on patch set 4 V +1 CR +1 06/29/19, 10:03

    Ok, so this approach works and is a nice to have for users but the main benefit would be to use this approach to speed up things in the core itself in all places where the core checks if an object is a LazyLoadingProxy and then fetches the real instance just to get the uid. This happens in the UriBuilder for instance but also in views, where hidden identity fields are generated.
  18. Daniel Goerz commented on patch set 4 06/29/19, 11:43

    LazyLoadingProxy.php:127

    Maybe we should add a little bit of context to the methods comment as well? For example the essence of the discussion in this patch.
  19. Oliver Klee voted on patch set 4 CR +1 06/29/19, 11:44

  20. Anja Leichsenring commented on patch set 4 08/30/19, 10:12

    @Daniel would you take the assignment? Seems to be stuck here.
  21. Daniel Goerz commented on patch set 4 CR +1 08/30/19, 10:43

    After reading the discussion again I don't think a comment is necessary here
  22. Anja Leichsenring wrote 09/09/19, 13:34

    Removed reviewer Anja Leichsenring.
  23. Daniel Goerz voted on patch set 4 V +1 10/23/19, 08:44

  24. Alexander Schnitzler commented on patch set 4 V +2 CR +2 10/23/19, 08:54

    LazyLoadingProxy.php:127 Reply

    No comment needed.
  25. Alexander Schnitzler merged patch set 5 10/23/19, 08:54