Project

General

Profile

Actions

Bug #91364

open

Extbase/CachingFramework - Serialization on 'Closure' is not allowed

Added by Carsten Hülsmann about 4 years ago. Updated about 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Caching
Target version:
-
Start date:
2020-05-12
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Files

Models.zip (5.74 KB) Models.zip Models Carsten Hülsmann, 2020-06-13 17:15

Related issues 4 (2 open2 closed)

Related to TYPO3 Core - Bug #91196: Exception for FileUpload field in multi-step formsClosed2020-04-25

Actions
Related to TYPO3 Core - Bug #91387: Relax constraints on serializing objectsClosedOliver Hader2020-05-13

Actions
Related to TYPO3 Core - Bug #91664: TYPO3 9.5 "Cannot unserialize TYPO3\CMS\Core\Locking\FileLockStrategy" during cache readingNew2020-06-17

Actions
Related to TYPO3 Core - Bug #95899: Try to cache an extbase queryResult leads to "Serialization of 'Closure' is not allowed"New2021-11-07

Actions
Actions #1

Updated by Susanne Moog about 4 years ago

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.

Actions #2

Updated by Carsten Hülsmann about 4 years ago

  • File Screenshot 2020-05-12 at 14.06.19.png added
  • File Product.php.zip added

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)

Actions #3

Updated by Carsten Hülsmann about 4 years ago

  • File deleted (Product.php.zip)
Actions #4

Updated by Carsten Hülsmann about 4 years ago

  • File Product.php.zip added
Actions #5

Updated by Oliver Hader about 4 years ago

  • Related to Bug #91196: Exception for FileUpload field in multi-step forms added
Actions #6

Updated by Carsten Hülsmann about 4 years ago

Just want to mention that this issue also appears now in latest 9.5.17.

Actions #7

Updated by Oliver Hader about 4 years ago

  • Related to Bug #91387: Relax constraints on serializing objects added
Actions #8

Updated by Oliver Hader about 4 years ago

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).

Actions #9

Updated by Carsten Hülsmann about 4 years ago

@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.

Actions #10

Updated by Carsten Hülsmann almost 4 years ago

Can be closed. It seems to be fixed with 9.5.19
I'll also check this in v10 during this weekend.

Actions #11

Updated by Carsten Hülsmann almost 4 years ago

  • File deleted (Screenshot 2020-05-12 at 11.07.50.png)
Actions #12

Updated by Carsten Hülsmann almost 4 years ago

  • File deleted (Screenshot 2020-05-12 at 14.06.19.png)
Actions #13

Updated by Carsten Hülsmann almost 4 years ago

  • File deleted (Product.php.zip)
Actions #14

Updated by Carsten Hülsmann almost 4 years ago

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.

Actions #15

Updated by Carsten Hülsmann almost 4 years ago

  • Related to Bug #91664: TYPO3 9.5 "Cannot unserialize TYPO3\CMS\Core\Locking\FileLockStrategy" during cache reading added
Actions #16

Updated by Oliver Hader almost 4 years ago

  • Status changed from New to Needs Feedback

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.php

Properties 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 vhs extension or some custom session-service or shopping-cart implementation...

Thx in advance!

Actions #17

Updated by Benni Mack over 2 years ago

  • Status changed from Needs Feedback to Closed

Closing this due to lack of feedback. Let me know if you think I should re-open this ticket.

Actions #18

Updated by Jan Kornblum over 2 years ago

I can confirm this for 10.4.20. Just changed some properties of my model to "Lazy", now "serialize()" throws this error.

Actions #19

Updated by Ruud Silvrants about 2 years ago

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;

```

Then the exception of the closure will occur.

Actions #20

Updated by Cyril Janody almost 2 years ago

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;
Actions #21

Updated by Daniel Schultheis over 1 year ago

  • PHP Version changed from 7.3 to 7.4

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?

Actions #22

Updated by Xavier Perseguers over 1 year ago

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.

Actions #23

Updated by Benni Mack over 1 year ago

  • Status changed from Closed to New
Actions #24

Updated by Benni Mack over 1 year ago

  • Related to Bug #95899: Try to cache an extbase queryResult leads to "Serialization of 'Closure' is not allowed" added
Actions #25

Updated by Benni Mack about 1 year ago

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.

Actions

Also available in: Atom PDF