Issue Bug Closed

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

Jan Kornblum 02/05/19, 01:07 updated 10/06/20, 18:03

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</f:for>

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

}

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.