mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Calling Doctrine\ORM\EntityManager::clear() with any arguments to clear specific entities is deprecated #6354
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ruudk on GitHub (Nov 26, 2019).
Originally assigned to: @lcobucci on GitHub.
Bug Report
Summary
Calling
Doctrine\ORM\EntityRepository::cleartriggers deprecation message:Current behavior
Doctrine\ORM\EntityRepository::cleardoes not any input and passes the call to$this->_em->clear($this->_class->rootEntityName);.I think we can just remove the
$this->_class->rootEntityNameargument here:a416a9a8b2/lib/Doctrine/ORM/EntityRepository.php (L133-L136)@lcobucci commented on GitHub (Nov 26, 2019):
Related to #7922. I think this method should just be removed instead of removing the argument.
@ruudk commented on GitHub (Nov 27, 2019):
Instead of doing that, shouldn't we just remove the argument for now to fix the deprecation? People that upgrade will get this deprecation now with no way to fix it.
Also, why should that method be removed? To me, it's handy to call clear on repository without having to do repo->getEntityManager->clear.
@Ocramius commented on GitHub (Nov 27, 2019):
Mostly needs to go because it is not up to a repository to control the
UnitOfWorkstate.@lcobucci commented on GitHub (Nov 27, 2019):
That would be a behavioural bc break, which is not really good (as we've seen in v2.6.5).
To me, we twisted the repository pattern with methods like that in this class.
The general idea of acting as an in-memory domain object collection is broken when my collection is still full of objects after I call
clear().Apart from that, it gives control over the identity map to components that should be completely unaware of it - harming encapsulation and leaking persistence details.
@lcobucci commented on GitHub (Dec 9, 2019):
Handled by #7928