Bug #87651

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

Added by Jan Kornblum 3 months ago. Updated about 1 month ago.

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

0%

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;
    }

}

History

#1 Updated by Markus Opahle about 1 month ago

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

#2 Updated by Claus Due about 1 month 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.

Also available in: Atom PDF