Bug #39562
FormViewHelper - Serialization of 'Closure' is not allowed
| Status: | New | Start date: | 2012-08-06 | |
|---|---|---|---|---|
| Priority: | Must have | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Fluid: ViewHelpers | |||
| Target version: | Core - 4.7.3 | |||
| Complexity: | ||||
| Votes: | 0 |
Description
I'm working on a TYPO3 4.7 project with rewrittenPropertyMapper enabled and I get the "Serialization of 'Closure' is not allowed" quite often.
The exception is thrown in typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php in line 262 and I'm using the latest 4.7 branch from git.
I have tried applying the patches from #32295 and #36820, but it isn't enough.
The $request->getArguments() fetches an array containing a domain model, but I can't figure out if domain models somehow refers to closures in some way.
But since the domain model is the only data which the FormViewHelper tries to serialize it must be it - in some way.
I haven't made use of any anonymous functions, so the questions is where I should try to dig in order to get it settled.
My domain model refers to several other models and some lazy loaded objectstorages as well
Related issues
| related to Extbase MVC Framework - Bug #32295: FLUIDTEMPLATE - Serialization of 'Closure' is not allowed | Resolved | 2011-12-05 | ||
| related to Core - Bug #36820: FLUIDTEMPLATE - Serialization of 'Closure' is not allowed | Resolved | 2012-05-03 |
History
Updated by Jacob Rasmussen 11 months ago
The site that I'm working on is using FLUIDTEMPLATE for rendering and the fluid form is set to not use cacheHash
Updated by Jacob Rasmussen 11 months ago
I did some more researching and the reason why this issue appears is because i'm using multiple steps:
In my controller I have a newAction -> createAction -> moreDataAction -> updateAction ...
And since I do a forward from my create to moreData action, I send the domain model as argument, which isn't a problem for the controller action, but for the form which needs to render the arguments - it isn't possible to serialize the domain model.
So... what's the best way to approach the issue, try to implement a sleep method in the domain models - or should some code be implemented in the FormViewHelper?
Updated by Jacob Rasmussen 11 months ago
I just tried adding a sleep function to Tx_Extbase_DomainObject_AbstractDomainObject
public function __sleep() {
return $this->_getProperties();
}
Which seems to do the trick, but is it an acceptable solution?
Updated by Jacob Rasmussen 10 months ago
Another note - first solution didn't work entirely as planned as it is necessary to rebuild the referring request in Tx_Extbase_MVC_Web_Request - which happens when a validation fails.
So I choose to employ an empty __sleep method instead - which works, but I guess that a discussion is needed on how Extbase should handle the situation properly.
As I see it, there are quite a few use-cases, where it is necessary to forward a domain model to an action, which in turn renders a form for editing. For example in a newsletter subscription where you could have a stored hash on each subscriber, and use the hash for lookup when the recipient wishes to make changes to his/hers subscription.
I'm in doubt on which parameters should be available for the FormViewHelper in such a situation
Updated by Cyrill Schumacher 10 months ago
- Target version set to 4.7.3
I'm having the exact same issue/problem and it is really anoying.
I'm only using an extended frontend user model with no closures.
The error happens when you reload a uncached page with a form in it.
Putting into my FE Model an empty __sleep method will do the trick and the error will not occur.
Updated by Anja Leichsenring 6 months ago
- Project changed from Extbase MVC Framework to Fluid
- Category changed from 963 to Fluid: ViewHelpers