Skip to content

Commit

Permalink
Merge pull request #6550 from alcaeus/fix-persistent-collection-return
Browse files Browse the repository at this point in the history
Fix return value of removeElement for extra lazy collections
  • Loading branch information
Ocramius authored Jul 22, 2017
2 parents fb3ec76 + 45e1817 commit 668ad4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lib/Doctrine/ORM/PersistentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,7 @@ public function removeElement($element)

$persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association);

if ($persister->removeElement($this, $element)) {
return $element;
}

return null;
return $persister->removeElement($this, $element);
}

$removed = parent::removeElement($element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,13 @@ public function testRemoveElementManyToMany()
$group = $this->_em->find(CmsGroup::class, $this->groupId);
$queryCount = $this->getCurrentQueryCount();

$user->groups->removeElement($group);
$this->assertTrue($user->groups->removeElement($group));

$this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a persisted entity should cause one query to be executed.");
$this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized.");

$this->assertFalse($user->groups->removeElement($group), "Removing an already removed element returns false");

// Test Many to Many removal with Entity state as new
$group = new CmsGroup();
$group->name = "A New group!";
Expand Down

0 comments on commit 668ad4c

Please sign in to comment.