Skip to content

Commit

Permalink
Merge branch 'fix/#6550-correct-return-value-of-extra-lazy-removeElem…
Browse files Browse the repository at this point in the history
…ent-calls' into 2.5

Backport #6550 to 2.5
  • Loading branch information
Ocramius committed Jul 22, 2017
2 parents c06f19d + 095b365 commit b3ceef0
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 @@ -375,11 +375,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 @@ -636,11 +636,13 @@ public function testRemoveElementManyToMany()
$group = $this->_em->find('Doctrine\Tests\Models\CMS\CmsGroup', $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 \Doctrine\Tests\Models\CMS\CmsGroup();
$group->name = "A New group!";
Expand Down

0 comments on commit b3ceef0

Please sign in to comment.