Review main Abandoned

65803[BUGFIX] Make getters of LazyLoadingProxy available for Fluid again

Stephan Großberndt CR 0 V 0 Normal +63 −1 updated 09/22/20, 12:27

Commit message

This patch makes AbstractDomainObject implement \ArrayAccess and load
the real Extbase Domain Model hidden behind a LazyLoadingProxy on
calling offsetGet(). This makes all magic getters of Extbase
Domain Models with @lazy annotation available for rendering in
Fluid again if they haven't been resolved yet, which is broken
since the removal of CmsVariableProvider in
TYPO3 v9.0 in https://review.typo3.org/c/Packages/TYPO3.CMS/+/53227

Fluid will only resolve the properties that are actually used in the
template, and only once - once resolved, the property value is
changed (because LazyLoadingProxy violates visibility and sets it on
the parent instance through forced reflection).

This is obviously also broken in v9.5 but will not be fixed there
anymore as the version only receives security relevant bugfixes.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 911

  1. Stephan Großberndt uploaded patch set 1 09/22/20, 08:36

  2. Alexander Schnitzler commented on patch set 1 09/22/20, 09:35

    AbstractDomainObject.php:388 Unresolved

    I dislike adding this since it makes possible to bypass all getters and setters and their visibility completely. And we already have "magic" methods that do this as well. See _setProperty and _getProperty. I understand that the implementation is broken but I also think that this has to be fixed on another level, i.e. on the caller side and not on the called side. Also, IMHO people need to understand bounded contexts and implement custom entities instead of building huge object trees and using lazy loading on all properties.
  3. Stephan Großberndt uploaded patch set 2 09/22/20, 10:06

  4. TYPO3com voted on patch set 2 V -1 09/22/20, 10:06 Completed build in 23s on Tue, 22 Sep, 10:06 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5808

  5. Stephan Großberndt commented on patch set 2 09/22/20, 10:07

    Thanks for the reply. :) I am fully aware this is a bugfix and not a grand new solution. Ideas on how to improve it are very welcome. Still it is a bug in released stable versions that must be fixed. I also understand using less of @lazy and implementing custom entities instead is better, but Extbase offers @lazy in stable versions and then Fluid must be able to access it (as it was). I updated the patch to use the magic methods _hasProperty, _getProperty and _setProperty (which already allowed access to all getters and setters disregarding their visibility). For Fluid on the other side the view is: Its an Extbase implementation detail where the argumentation is the called side should handle it. The CmsVariableProvider, which sat in between has been removed, Claus Dues statement in https://github.com/TYPO3/Fluid/issues/513#issuecomment-594823546 was: "I don't think that restoring this custom implementation of VariableProvider in TYPO3 CMS is the right solution. Ideally the progress would be toward fewer custom implementations, not more." If restoring it anyway is a solution to fix this with both of you being more happy, lets do it. Maybe Benny (who removed the CmsVariableProvider), could have a word with us on this too.
  6. Stephan Großberndt uploaded patch set 3 09/22/20, 10:09

  7. TYPO3com voted on patch set 3 V -1 09/22/20, 10:21 Completed build in 11m 12s on Tue, 22 Sep, 10:21 AM Test Summary: 3 of 74143 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5809

  8. Stephan Großberndt commented on patch set 3 V -1 09/22/20, 10:35

    The proposed implementation is not working correctly as e.g. \TYPO3\CMS\Extbase\Mvc\View\JsonView::transformValue) checks if (is_array($value) || $value instanceof \ArrayAccess) { which leads to Extbase Domain Models implementing \ArrayAccess not being rendered anymore as JSON (and instead as an empty array).
  9. Alexander Schnitzler commented on patch set 3 09/22/20, 10:41

    > Patch Set 3: Verified-1 > > The proposed implementation is not working correctly as e.g. \TYPO3\CMS\Extbase\Mvc\View\JsonView::transformValue) checks > > if (is_array($value) || $value instanceof \ArrayAccess) { > > which leads to Extbase Domain Models implementing \ArrayAccess not being rendered anymore as JSON (and instead as an empty array). Great, now one ugly implementation (JsonView) prevents fixing another ugly implementation. That's why there is no easy fix in Extbase. Anyway, regarding pragmatism: I won't downvote patches in the Extbase area that are fully upvoted by others. I'm fine with those but I can't emphasize enough how much I got burnt trying to fix issues with small patches rather than rethinking the issue in a whole. That's why I don't tackle bug reports but only focus on new, IMHO more sensible implementations that replace whole areas.
  10. Claus Due commented on patch set 3 09/22/20, 10:49

    I still say that a true fix for this requires rethinking LazyLoadingProxy, to avoid magic methods as well as visibility violation. While the ArrayAccess pattern is OK-ish for solving third party implementations I do not think it is the right way to implement it across the board on all DomainObject instances. If nothing else, it would cause any third party code which does the same check JsonView currently does, to fail in a similar way.
  11. Stephan Großberndt abandoned the change 09/22/20, 12:27

    interferes with extbase internals breaking json output and objectaccess