[FLOW3-general] Object argument becomes null

Sebastian Kurfürst sebastian at typo3.org
Mon Jul 26 08:25:48 CEST 2010


Hey Scott,

by doing a "forward()", you (internally) do another call to a different
action. This however has the consequences that the Property Mapping is
done internally again -- which cannot handle not-yet-persisted objects.

I think the following happens:
1) createAction: The $disc object is created from the input array, and
added to the repository. However, it is not yet persisted, as this is
done lazily after the request.
2) When doing the redirect, the system notices that $disc is an instance
of ...Domain\Model\Disc, and sees that it is an entity. That's why it
tries to convert it to a UUID (as that is what would happen when a
normal URL is generated). However, as it does not have a UUID yet
(because it is not yet persisted), this fails.
3) The redirect() causes the action to be started *from scratch*, i.e.
the controller will be re-initialized (that's why $this->disc and the
like are not available anymore).
4) editAction() now receives a NULL argument because the mapping
beforehand failed -- that's where the error becomes first visible.

There are different possible approaches to fix this issue:

1) Just call $this->editAction(...) if this makes sense, or extract the
common logic into a separate method.
2) Change the logic of forward(), to first persist the objects before
the forward() is executed.

To me, the 2nd solution looks more clean, but it'd be great if others
(Robert, Karsten, ...) could also state their opinion here.

Hope this helps a bit,
Greets,
Sebastian


More information about the FLOW3-general mailing list