0

EDIT for those claiming "duplicate" question. Assume I don't know what entities I want to check. I want to check ALL CHANGES. Not "what was changed on entity x that I dont have a reference to.

Imagine I do this:

$e1 = $repo->find(1);
$e2 = $repo->find(2);
$e3 = $repo->find(3);

$e1->setMyName('xxx');
$e2->setMyName('yyy');
$e3->setMyName('zzz');

Then I forget about these changes, or forget to roll them back (not even sure how you would undo something like that).

Then at some distant place in the code, I call flush() and I wonder "why is my_name set to "zzz" at some record, don't recall doing so."

Is there a way to easily see what flush is actually doing?

Toskan
  • 13,911
  • 14
  • 95
  • 185
  • If you need to see changes, you can get changeset for the entity, `$uow = $em->getUnitOfWork(); $uow->computeChangeSets(); $uow->getEntityChangeSet($entity)` – Artem Apr 28 '22 at 09:18
  • In such case I would check the symfony profiler. It has a doctrine tab which has all of it. – Jenne Apr 28 '22 at 09:27
  • Create your own [logger](https://symfony.com/doc/current/logging.html) using the *LoggerInterface* and log just before the flush. – Bossman Apr 28 '22 at 09:58

0 Answers0