[TYPO3-mvc] Fluid: SelectViewHelper and LazyLoading

Marc Bastian Heinrichs typo3 at mbh-web.de
Tue Jul 30 10:35:00 CEST 2013


Hi Daan,

I would call it a bug. I created a issue
http://forge.typo3.org/issues/50548
and will push a patch in a minute.

Could you test it then, please. THX

Best
Marc Bastian

Am 30.07.2013 10:04, schrieb Daan Wissing:
> Hi all,
> 
> I might have stumbled across an issue introduced in TYPO3 6.1,
> considering the SelectViewHelper and the rewritten PersistenceManager.
> Situation: I have a model (generated with the Extension Manager) as
> follows: a Driver drives for one Transporter, while a Transporter can
> have many Drivers (a 1:n relation). Meanwhile, the Transporter can
> transport for one or more Customers, while a Customer can have multiple
> Transporters (a m:n relation). Both relations are defined as @lazy.
> 
> Now, I want to edit a Driver and use a Fluid SelectViewHelper to choose
> from any Transporter. Fluid code:
> <f:form.select options="{transporters}" property="transporter"
> optionLabelField="name" />
> {transporters} is a QueryResult containing all transporters.
> 
> In 6.0, this worked like a charm. But when upgrading to 6.1, I got an
> Exception:  Object of class
> TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage could not be
> converted to string.
> 
> After a lot of investigating, I came upon the following:
> 1. In 6.0, the function PersistenceManager::getIdentifierByObject()
> would load a lazy object if it was not loaded yet. In 6.1 this is not
> the case, the object is merely checked to be loaded in the
> persistenceSession.
> 2. Because of this, the function SelectViewHelper::getSelectedValue()
> will get a LazyLoadedProxy object (a Transporter) as current Value. 3.
> Because LazyLoadedProxy implements \Iterator, getSelectedValue() will
> iterate over all properties of the Transporter, including the connected
> Customers. 4. Customers is lazily loaded, so in this stage it is still a
> LazyObjectStorage. But the function
> SelectViewHelper::getOptionValueScalar() tries to call the __toString()
> method on this storage, which is not implemented, thus throwing the
> Exception.
> 
> I suspect that iterating over all the properties of a Transporter in
> point 3 is not intended behaviour, as this chunck of code is (I think)
> intended for dealing with multi selects. I have found a work-around for
> this (defining optionValueField="uid" in the f:form.select), but I am
> not sure if this is the intended method and I have been using an
> undocumented feature(tm), or if this is truly a bug.



More information about the TYPO3-project-typo3v4mvc mailing list