DDC-2496: Unexpected behaviour flushing single entity #3133

Open
opened 2026-01-22 14:13:13 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 10, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user hrajchert:

The following works as expected:
$existingElement = $repository->find(1);
$existingElement->setSomething('foo');
$newElement = new Element('bar');
$em->persist($newElement);
$em->flush($newElement);
// The new element is added and the existing is not modified

The following does not:
$existingElement = $repository->find(1);
$em->remove(existingElement);
$newElement = new Element('bar');
$em->persist($newElement);
$em->flush($newElement);
// The new element is added and the existing is deleted (i didnt flush THAT element)

The following does not:
$newElement2 = new Element('foo');
$em->persist($newElement2);
$newElement = new Element('bar');
$em->persist($newElement);
$em->flush($newElement);
// Both elements are persisted, even if I only flushed $newElement

Originally created by @doctrinebot on GitHub (Jun 10, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user hrajchert: The following works as expected: $existingElement = $repository->find(1); $existingElement->setSomething('foo'); $newElement = new Element('bar'); $em->persist($newElement); $em->flush($newElement); // The new element is added and the existing is not modified The following does not: $existingElement = $repository->find(1); $em->remove(existingElement); $newElement = new Element('bar'); $em->persist($newElement); $em->flush($newElement); // The new element is added and the existing is deleted (i didnt flush THAT element) The following does not: $newElement2 = new Element('foo'); $em->persist($newElement2); $newElement = new Element('bar'); $em->persist($newElement); $em->flush($newElement); // Both elements are persisted, even if I only flushed $newElement
admin added the Bug label 2026-01-22 14:13:13 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3133