-
-
Couldn't load subscription status.
- Fork 190
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
A simple class like this:
class ExampleEvent {
public function __construct(public SomeDoctrineEntity $doctrineEntity) {}
}
Should strip the doctrine entity (and possible AOP advices on serialize($exampleEventInstance); but it doesn't which leads to serialize errors due to closures used in advices and sometimes entities.
This worked in < 9.0 and was broken with the reworked proxy building.
\Neos\Flow\ObjectManagement\DependencyInjection\ProxyClassBuilder::buildSerializeRelatedEntitiesCode now skips the Flow_serializeRelatedEntities under some conditions (see early returns) which wasn't the case previously. Unfortunately the early returns do not check for entity properties nor for advices (both might be difficult to know at proxy building time).
I think this was done to reduce the amount of proxies we create as we basically generated a __sleep for every class before, however we either need a way to bypass this skip or tighten our conditions to make this waterproof as the resulting error is hard to debug and understand.
A workaround is to add a useless transient property to the respective class ala:
use Neos\Flow\Annotations as Flow;
class ExampleEvent {
/**
* Do not remove, this is a workaround for Flows proxy building
* @Flow\Transient
* @var null
*/
protected null $flowProxyFix = null;
public function __construct(public SomeDoctrineEntity $doctrineEntity) {}
}
Which then triggers the proxy building of the necessary __sleep method.
Expected Behavior
Proxy gets __sleep method to extract unwanted doctrine proxy before serialization.
Steps To Reproduce
No response
Environment
- Flow: 9.0
- PHP: xxAnything else?
No response