Bug #87651

Lazy loading (sometimes) not working in Fluid (only n:1 relations)

Added by Jan Kornblum over 2 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2019-02-05
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I've got several domain objects which contain serveral n:1 relations (1:n relations, too, but these work as expected). Accessing the related objects in fluid inside a <f:for> sometimes returns nothing for some relations. Accessing the same relation from a single object instead, retrives the relation

All relations are setup exactly up equal (in model, tca, ext_tables.sql). Example:

<f:for each="{customers}" as="customer">
   {customer.category.title} // works
   {customer.status.title} // doesn't work (but <f:debug>{customer.status}</f:debug> works)
<f:for>

<f:for each="{contacts}" as="contact">
   {contact.category.title} // works
   {contact.position.title} // doesn't work (but <f:debug>{contact.position}</f:debug> works)
<f:for>

As i said, all relations are defined exactly the same way! I don't make use of any '_loadRealInstance()' in my models - should this be neccessary? Example part of a model:


class Customer extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{

    /**
     * Category
     *
     * @var \Vendor\Ext\Domain\Model\CustomerCategory
     * @lazy
     */
    protected $category = null;

    /**
     * Returns the category
     *
     * @return \Vendor\Ext\Domain\Model\CustomerCategory $category
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * Sets the category
     *
     * @param \Vendor\Ext\Domain\Model\CustomerCategory $category
     * @return void
     */
    public function setCategory(\Vendor\Ext\Domain\Model\CustomerCategory $category = NULL)
    {
        $this->category = $category;
    }

}


Related issues

Related to TYPO3 Core - Bug #90215: Getters of class LazyLoadingProxy can't be called by FluidAccepted2020-01-27

Actions
Related to TYPO3 Core - Bug #87899: Magic getters stop to be evaluated in Fluid starting from TYPO3 9Closed2019-03-13

Actions
#1

Updated by Markus Opahle over 2 years ago

Looks like \TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider cannot handle the magic methods from LazyLoadingProxy

#2

Updated by Claus Due over 2 years ago

  • Status changed from New to Resolved

See https://github.com/TYPO3/Fluid/pull/438 which solves this. Will be in the next release of Fluid.

Closing the issue since the problem is not in TYPO3 CMS.

#3

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
#4

Updated by Steffen Müller almost 2 years ago

This fix in not applied in TYPO3 9.5.8, currently only in TYPO3/Fluid master.
AFAIK it would require
- [ ] backporting the patch to 2.6 branch,
- [ ] releasing TYPO3/Fluid 2.6.2
- [ ] releasing new version of typo3-cms/fluid

#5

Updated by Till Wimmer almost 2 years ago

It's not solved in 9.5.9 either.

Will this be fixed? It makes our extensions partly unusable, or we have to remove lazy loading.

I also get problems when passing certain properties with lazy loading to repositorie's find methods.

E.g.

myRepositpory->findByMessungAndJahr($status->getMessung(), $status->getJahr());

throws
Argument 2 passed to ... mmust be an instance of ...\Jahr instance of TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy given

Both Messung and Jahr are lazy properties, but strangely there is only an issue with Jahr.

Before migrating to 9.x we did not have these issues.

#6

Updated by Steffen Müller almost 2 years ago

current TYPO3/Fluid release 2.6.4 fixes the issue,
composer installations should receive the fix

#7

Updated by Till Wimmer almost 2 years ago

Thanks for the info. And when do non-composer installations receive the fix?

#8

Updated by Chris no-lastname-given over 1 year ago

I can confirm this issue with TYPO3 9.5.10 (non-composer installation).

#9

Updated by Chris no-lastname-given over 1 year ago

Chris no-lastname-given wrote:

I can confirm this issue with TYPO3 9.5.10 (non-composer installation).

I have to correct myself:
With TYPO3 9.5.10 it is working for me, but not with 9.5.11 (non-composer installation). Interesting...

#10

Updated by Felix Holler over 1 year ago

Chris no-lastname-given wrote:

Chris no-lastname-given wrote:

I can confirm this issue with TYPO3 9.5.10 (non-composer installation).

I have to correct myself:
With TYPO3 9.5.10 it is working for me, but not with 9.5.11 (non-composer installation). Interesting...

Can also confirm. in 9.5.11 non comoser installation the problem is not fixed but in 9.5.10

#11

Updated by Chris no-lastname-given over 1 year ago

Problem still extists with TYPO3 9.5.13 in non composer installation. I have opened a new issue (#90215), which points to this one.

#12

Updated by Chris no-lastname-given over 1 year ago

  • Related to Bug #90215: Getters of class LazyLoadingProxy can't be called by Fluid added
#13

Updated by Stephan Großberndt 10 months ago

  • Related to Bug #87899: Magic getters stop to be evaluated in Fluid starting from TYPO3 9 added
#14

Updated by Tizian Schmidlin 10 months ago

I can confirm this issue also exists in 9.5.22, should I require fluid in a higher version and try to bypass TYPO3's requirements?
EDIT: it was a misconfiguration and an erroneous content that led to the "bad" behaviour, could not reproduce in TYPO3 9.5.22

Also available in: Atom PDF