#91364Extbase/CachingFramework - Serialization on 'Closure' is not allowed
Description
Hi,
I recently updated an Instance from 9.5 to 10.4.1.
Since then I receive the Error (see attached screen), in our showProduct action.
This seems to be related to the Domain Model Object (cause if this is not part of the $items array the serialization works).
I already tried to handle this via a json_encode but with this I’ll loose all relations (and especially this makes it required to cache the product object in cache).
I also tried to store the whole view in the cache which leads to the exact same error.
Important steps that happened:
- Updated whole Controller to use Symfony DI
- Updated Extension Config (registerPlugin/Module)
Any suggestion or hint would help.
Reviews 3
Related issues 4
- Bug #91196Exception for FileUpload field in multi-step forms
- Bug #91387Relax constraints on serializing objects
- Bug #91664TYPO3 9.5 "Cannot unserialize TYPO3\CMS\Core\Locking\FileLockStrategy" during cache reading
- Bug #95899Try to cache an extbase queryResult leads to "Serialization of 'Closure' is not allowed"
Files 1
History 26
Show 1 earlier messages
-
Carsten Hülsmann commented and changed attached Screenshot 2020-05-12 at 14.06.19.png attached Product.php.zip <span data-processor="relativetime" data-value="2020-05-12T14:11:05+00:00" > 05/12/20, 14:11 </span>
Susanne Moog wrote:
> Does the domain model object (or any of it’s relations) contain for example a Logger or similar? Basically the error says that you have a closure somewhere in the object structure to be serialized, which you should probably unset (or use __sleep/wakeup) before serialisation.Hi Susanne,
thanks for you response so far.Not that I’m aware of. We generally didn’t adjust something in the models with the update from 9.5. Shouldn’t this error appear there as well in this case?
Attached the Product Model file.I just updated to 10.4.2 and the error is the same but the Stack has an additional error now (see screen)
-
Carsten Hülsmann changed
Product.php.zip<span data-processor="relativetime" data-value="2020-05-12T15:04:39+00:00" > 05/12/20, 15:04 </span> -
Carsten Hülsmann changed attached Product.php.zip <span data-processor="relativetime" data-value="2020-05-12T15:05:50+00:00" > 05/12/20, 15:05 </span>
-
Oliver Hader changed Related to #91196 <span data-processor="relativetime" data-value="2020-05-12T16:04:13+00:00" > 05/12/20, 16:04 </span>
-
Carsten Hülsmann commented <span data-processor="relativetime" data-value="2020-05-13T10:31:17+00:00" > 05/13/20, 10:31 </span>
Just want to mention that this issue also appears now in latest 9.5.17.
-
Oliver Hader changed Related to #91387 <span data-processor="relativetime" data-value="2020-05-18T14:59:35+00:00" > 05/18/20, 14:59 </span>
-
Oliver Hader commented <span data-processor="relativetime" data-value="2020-05-18T15:04:09+00:00" > 05/18/20, 15:04 </span>
Probably some of the models is using a File or FileReference – in that’s my assumption is true, the problem is the same as in #91196 (files having an instance of EventDispatcher, which has Closures).
-
Carsten Hülsmann commented <span data-processor="relativetime" data-value="2020-05-20T08:26:53+00:00" > 05/20/20, 08:26 </span>
@Oliver – there are no file or FileReference relations in these models.
The models only have References to other models (ObjectReference) and to the sys_categories
I just updated to 10.4.3 but the issue is the same.
I doublechecked everything once more. It is definitly an issue with the relations in the model.
As soon as I’d remove all relations from it (even those to itself) the serialization is working.As said I only have Relations (via ObjectStorage incl. @Lazy) to sys_category and the Product Model itself and a Document model.
Product as well as Document doesn’t have any closures inside.This is really an issue cause it prevents us not only from upgrading to 10 but also within the 9 LTS version.
-
Carsten Hülsmann commented <span data-processor="relativetime" data-value="2020-06-12T23:26:04+00:00" > 06/12/20, 23:26 </span>
Can be closed. It seems to be fixed with 9.5.19
I’ll also check this in v10 during this weekend. -
Carsten Hülsmann changed
Screenshot 2020-05-12 at 11.07.50.png<span data-processor="relativetime" data-value="2020-06-12T23:26:10+00:00" > 06/12/20, 23:26 </span> -
Carsten Hülsmann changed
Screenshot 2020-05-12 at 14.06.19.png<span data-processor="relativetime" data-value="2020-06-12T23:26:14+00:00" > 06/12/20, 23:26 </span> -
Carsten Hülsmann changed
Product.php.zip<span data-processor="relativetime" data-value="2020-06-12T23:26:19+00:00" > 06/12/20, 23:26 </span> -
Carsten Hülsmann commented and changed attached Models.zip <span data-processor="relativetime" data-value="2020-06-13T17:15:19+00:00" > 06/13/20, 17:15 </span>
Unfortunately this issue is still present in 10.4.4.
Attached the models which are failing. As you can see there are no File or FileReferences inside. -
Carsten Hülsmann changed Related to #91664 <span data-processor="relativetime" data-value="2020-06-17T08:29:17+00:00" > 06/17/20, 08:29 </span>
-
Oliver Hader commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2020-07-02T18:05:59+00:00" > 07/02/20, 18:05 </span>I was not able to reproduce this behavior with TYPO3 v10.4.5-dev using the following model implementation (in the scope of the “information” plugin of that extension):
https://github.com/ohader/car-rental-extbase/blob/master/packages/car-rental-b/Classes/Domain/Model/Rental/Car.phpProperties are using lazy-storages for 1:1 and 1:n and all were given when testing the scenario.
In order to analyze this further, please
- add the stack-traces – without details it’s kind of impossible to debug these things
- provide information on what it probably special in your extension, e.g. using
vhsextension or some custom session-service or shopping-cart implementation…
Thx in advance!
-
Benni Mack commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2021-12-15T16:32:41+00:00" > 12/15/21, 16:32 </span>Closing this due to lack of feedback. Let me know if you think I should re-open this ticket.
-
Jan Kornblum commented <span data-processor="relativetime" data-value="2021-12-22T16:40:48+00:00" > 12/22/21, 16:40 </span>
I can confirm this for 10.4.20. Just changed some properties of my model to “Lazy”, now “serialize()” throws this error.
-
Ruud Silvrants commented <span data-processor="relativetime" data-value="2022-05-10T10:18:25+00:00" > 05/10/22, 10:18 </span>
Can confirm this still occurs, TYPO3 version 10.4.27.
Simple reproduction:
-Use a domain model with an @lazy property, for example ext:news domain model News:```
/** * Fal media items * *var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\FileReference> *TYPO3\CMS\Extbase\Annotation\ORM\Lazy
*/
protected $falMedia;```
When this property is used in extbase form the VH `Web/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php` will try to serialize:
```
$result .= ‘<input type="hidden" name="' . htmlspecialchars($this->prefixFieldName(‘__referrer[arguments]’)) . ‘” value=”’ . htmlspecialchars($this->hashService->appendHmac(base64_encode(serialize($request->getArguments())))) . ‘” />’ . LF;</p> <p>```</p> <p>Then the exception of the closure will occur.</p>"> -
Cyril Janody commented <span data-processor="relativetime" data-value="2022-05-26T14:54:15+00:00" > 05/26/22, 14:54 </span>
I can also confirm it with TYPO3 10.4.28.
Reproduction:
Use the Form ViewHelper with a domain model having a relation to a system category (which has a @lazy definition on its parent property)./** * @var \TYPO3\CMS\Extbase\Domain\Model\Category|null * @Extbase\ORM\Lazy */ protected $parent;
(1/1) Exception Serialization of 'Closure' is not allowed in /var/www/html/private/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php line 291 $result .= '<input type="hidden" name="' . htmlspecialchars($this->prefixFieldName('__referrer[arguments]')) . '" value="' . htmlspecialchars($this->hashService->appendHmac(base64_encode(serialize($request->getArguments())))) . '" />' . LF; -
Daniel Schultheis commented and changed PHP Version
7.37.4 <span data-processor="relativetime" data-value="2022-10-17T13:37:21+00:00" > 10/17/22, 13:37 </span>I can also confirm that this still happens with TYPO3 10.4.32.
As previous posts already mentioned this happens as soon as a domain model or a related domain model (direct reference or via ObjectStorage) is using the lazy loading annotation, that model is a method parameter of the called action in the controller and the template is using the FormViewHelper to render a form.
The only workaround available is removing any lazy loading from any properties and the properties of related models which might not be possible if for instance system categories are used.
Can anyone confirm if this is still a problem in TYPO3 11?
Will this problem ever be fixed for TYPO3 10? -
Xavier Perseguers commented <span data-processor="relativetime" data-value="2022-12-09T13:48:04+00:00" > 12/09/22, 13:48 </span>
Damn! I hit this very problem in TYPO3 v10 :(
I hacked by passing an integer (uid) instead of the object to the method I’m possibly forwarding to. That solves that bug.
-
Benni Mack changed status
ClosedNew <span data-processor="relativetime" data-value="2022-12-09T14:05:00+00:00" > 12/09/22, 14:05 </span> -
Benni Mack changed Related to #95899 <span data-processor="relativetime" data-value="2022-12-21T08:16:53+00:00" > 12/21/22, 08:16 </span>
-
Benni Mack commented <span data-processor="relativetime" data-value="2023-05-09T20:26:18+00:00" > 05/09/23, 20:26 </span>
Background (as I ran into this problem as well) is IMHO:
I have a relation which is bi-directional (imagine “$material->getCategories()” and “$category->getMaterials()”) which both have the lazy attribute, which I had used in a Extbase form. Removing the attribute resulted into a PHP memory error. Removing one of the relations (which I did not need directly), made it work.
-
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-08-27T19:52:30+00:00" > 08/27/26, 19:52 </span>closing as duplicate of #95899
Does the domain model object (or any of it’s relations) contain for example a Logger or similar? Basically the error says that you have a closure somewhere in the object structure to be serialized, which you should probably unset (or use __sleep/wakeup) before serialisation.