UnitOfWork::commit with specific entity flashes all removed and persisted entity but not change dependent entity #5313

Open
opened 2026-01-22 15:04:09 +01:00 by admin · 2 comments
Owner

Originally created by @SergeyMilegov on GitHub (Nov 4, 2016).

$category = $this->getCategoryRepository()->find(1);
foreach ($category->getProducts() as $product) {
    $this->getEntityManager()->remove($product);
}
$article = $this->getArticleRepository()->find(1);
$article->setTitle('New Title');

$this->getEntityManager()->flush($article);// flushing article, removing products, but don't touching $category::products
$this->getEntityManager()->flush();// fatal error: A new entity was found through the relationship 'Category#products' that was not configured to cascade persist operations for entity: Product@XXXXX
Originally created by @SergeyMilegov on GitHub (Nov 4, 2016). ``` $category = $this->getCategoryRepository()->find(1); foreach ($category->getProducts() as $product) { $this->getEntityManager()->remove($product); } $article = $this->getArticleRepository()->find(1); $article->setTitle('New Title'); $this->getEntityManager()->flush($article);// flushing article, removing products, but don't touching $category::products $this->getEntityManager()->flush();// fatal error: A new entity was found through the relationship 'Category#products' that was not configured to cascade persist operations for entity: Product@XXXXX ```
admin added the BugMissing Tests labels 2026-01-22 15:04:09 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 5, 2016):

Need a test case to reproduce this. Seems like one of the usual flush($somethingSpecific) issues. Dropping support for that can't come soon enough!

@Ocramius commented on GitHub (Nov 5, 2016): Need a test case to reproduce this. Seems like one of the usual `flush($somethingSpecific)` issues. Dropping support for that can't come soon enough!
Author
Owner

@Ocramius commented on GitHub (Nov 5, 2016):

Raised #6118, since this flush($something) stuff will NEVER end (it cannot by design limitations of the UnitOfWork)

@Ocramius commented on GitHub (Nov 5, 2016): Raised #6118, since this `flush($something)` stuff will NEVER end (it cannot by design limitations of the `UnitOfWork`)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5313