Bug #29405

When storing a new entity inside the session, it will be fully serialized instead of just the reference being stored

Added by Sebastian Kurfuerst almost 4 years ago. Updated over 2 years ago.

Status:New Start date:2011-09-01
Priority:Must have Due date:
Assigned To:- % Done:

0%

Category:Session
Target version:-
PHP Version: Complexity:
Has patch: Affected Flow version:FLOW3 1.0.0

Description

When having the following code:

1$newEntity = new MyEntity();
2$newEntityRepository->add($newEntity);
3
4$someObjectWithSessionScope->setEntity($newEntity);

Then, $newEntity is FULLY serialized; although it should only be stored as UUID reference in the session.

As an example, this happens when running the BlogExample setup; after creating an initial user -- this user is directly logged in, but the Account is fully stored in the session.

This leads to very weird bugs, in my case I wanted to store a reference to $account in another entity; and doctrine then told me that the object was not known yet.

The issue is in DependencyInjection\ProxyClassBuilder::buildSerializeRelatedEntitiesCode around line 239:

1if (\$this->\$propertyName instanceof \\TYPO3\\FLOW3\\Persistence\\Aspect\\PersistenceMagicInterface && !\\TYPO3\\FLOW3\\Core\\Bootstrap::\$staticObjectManager->get('TYPO3\\FLOW3\\Persistence\\PersistenceManagerInterface')->isNewObject(\$this->\$propertyName) || \$this->\$propertyName instanceof \\Doctrine\\ORM\\Proxy\\Proxy) {
2                if (!property_exists(\$this, 'FLOW3_Persistence_RelatedEntities') || !is_array(\$this->FLOW3_Persistence_RelatedEntities)) {
3

Basically this check somehow needs to be adjusted, such that:
1) New objects which are scheduled for addition are serialized as UUID
2) New objects which are NOT scheduled for addition are serialized completely.

@Karsten: Any hints on how we can check that? It seems that PersistenceManagerInterface.::isNewObject also returns TRUE when the object is not known at all to the unit of work. Maybe we need to extend PersistenceManagerInterface then?

History

#1 Updated by Robert Lemke almost 4 years ago

  • Target version changed from 1.0 beta 2 to 1.0.0

#2 Updated by Karsten Dambekalns almost 4 years ago

  • Target version deleted (1.0.0)

#3 Updated by Karsten Dambekalns almost 4 years ago

  • Affected Flow version set to FLOW3 1.0.0

#4 Updated by Benno Weinzierl over 2 years ago

Is that issue still relevant?

I am asking because we have an other issue with session scope objects getting another session scope object injected.
This works for one request, after that it results in a ugly apache seg-fault (i suspect because the injected session object is also stored and not reinjected).
I fixed it with @Flow\Transient but it would be nice to make session scope objects work as expected auto of the box.

Also available in: Atom PDF