doctrine / doctrine/orm

Embedded class not changed, but keeps being marked as changed in the EntityChangeset

Open
#7,204 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
10.2k
Forks
2.5k
Avg merge
1d 10h
Merged PRs (30d)
34

Description

- SLC enabled
- Entity with a Embedded class

I am not sure how to recreate this so suggestions are very welcome. My guess is it has to do with SLC.

Sometimes the Embedded class is marked as changed because it fails:
```php
// skip if value haven't changed
if ($orgValue === $actualValue) {
continue;
}
```
in the UnitOfWerk @695. But the strange thing is, nothing has changed in this embedded class. Other props in the parent have changed but nothing in the embedded class.

Because it is marked as changed, the Subscribers get triggered and more unexpected behavior happens. Like trying to commit "something" to the DB, but nothing changed. I can even see the blank transactions and commits in my SQL log:

```
====
Query: "START TRANSACTION"
Params:

Types:

====

====
Query: "COMMIT"
Params:

Types:

====
```

Now the annoying thing is that this keeps being marked as changed. So when i call for the entity another time in a new request and just flush the EM, it is again marked as changed (that's why i think SLC has something to do with this)

The second request:
```php
$em = $this->app->getEntityManager();
$entity = $em->find(Account::class, $id);
$em->flush();
```

So because the Embedded class keeps being marked as changed, even the above lines keep triggering the Subscribers and keep making the empty DB commits.

After running, `redis-cli flushall`, everything is back to normal, but after some changes to the parent class, it sometimes unexpectedly again marks the embedded class as changed and the issue keeps persisting until flushall is called again.

Again, i am having a hard time to reproducing this but any suggestions would be appreciated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.