Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store PersistentCollection changes in entity change set as array #9939

Open
wants to merge 2 commits into
base: 3.0.x
Choose a base branch
from

Conversation

franmomu
Copy link
Contributor

The property $entityChangeSets of UnitOfWork stores entity changes as an array of two items for each property changed.

/**
* Map of entity changes. Keys are object ids (spl_object_id).
* Filled at the beginning of a commit of the UnitOfWork and cleaned at the end.
*
* @psalm-var array<int, array<string, array{mixed, mixed}>>
*/
private array $entityChangeSets = [];

But for Collection it has another behaviour as pointed out in #8955 and changed the phpdoc in #8959.

That was added in 65bbdc3.

This PR modifies that case storing an array instead of the PersistentCollection, this will allow PreUpdateEventArgs to extend from PreUpdateEventArgs of doctrine/persistence.

I'm not sure if this is the right fix, but apparently the test added in the original commit passes with this change.

UPGRADE.md Outdated Show resolved Hide resolved
UPGRADE.md Outdated Show resolved Hide resolved
@greg0ire greg0ire requested a review from beberlei July 28, 2022 14:59
@@ -683,7 +683,7 @@ public function computeChangeSet(ClassMetadata $class, object $entity): void
}

$this->collectionDeletions[$coid] = $orgValue;
$changeSet[$propName] = $orgValue; // Signal changeset, to-many assocs will be ignored.
$changeSet[$propName] = [$orgValue, $actualData];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this change will leave dead code somewhere that handled the non-array value of $changeSet[$propName] = $orgValue;, but I haven't found any.

@franmomu franmomu force-pushed the fix_entity_changeset_persistent_collection branch 2 times, most recently from 40216fc to 60a407a Compare July 29, 2022 06:13
@franmomu franmomu force-pushed the fix_entity_changeset_persistent_collection branch 3 times, most recently from 702daeb to 0942222 Compare August 8, 2022 05:49
SenseException
SenseException previously approved these changes Aug 15, 2022
greg0ire
greg0ire previously approved these changes Jan 5, 2023
@derrabus
Copy link
Member

derrabus commented Jan 6, 2023

Can we prepare this change on 2.x somehow, e.g. by allowing apps to opt-in to it?

SenseException
SenseException previously approved these changes Jan 11, 2023
The property $entityChangeSets of UnitOfWork stores entity changes
as an array of two items for each property changed. Before this
change, when an entity with a property holding a Collection was
changed, $entityChangeSets stored only the old Collection.
@franmomu franmomu force-pushed the fix_entity_changeset_persistent_collection branch 2 times, most recently from 754fde3 to 211347d Compare November 20, 2023 22:23
@franmomu franmomu force-pushed the fix_entity_changeset_persistent_collection branch from 211347d to f0df183 Compare November 20, 2023 22:28
@franmomu
Copy link
Contributor Author

I forgot about this PR.

Can we prepare this change on 2.x somehow, e.g. by allowing apps to opt-in to it?

I cannot think a way to do that 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants