oauth2-bundle
oauth2-bundle copied to clipboard
Managers should only flush their entities
Currently, any manager implemented in this bundle calls flush(), ie. Manager/Doctrine/AccessTokenManager.php:35
It would be better to flush only one created entity.
Example from \Trikoder\Bundle\OAuth2Bundle\Manager\Doctrine\AccessTokenManager
Instead of:
public function save(AccessToken $accessToken): void
{
$this->entityManager->persist($accessToken);
$this->entityManager->flush();
}
use
public function save(AccessToken $accessToken): void
{
$this->entityManager->persist($accessToken);
$this->entityManager->flush($accessToken);
}
The behavior of flushing only one entity to the database via the flush method was deprecated a couple of years ago and was removed for Doctrine 3.0.
https://github.com/doctrine/orm/blob/master/UPGRADE.md#bc-break-removed-entitymanagerflushentity-and-entitymanagerflushentities
https://github.com/doctrine/orm/issues/6118