oauth2-bundle icon indicating copy to clipboard operation
oauth2-bundle copied to clipboard

Managers should only flush their entities

Open alenpokos opened this issue 6 years ago • 1 comments

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);
    }

alenpokos avatar Feb 11 '19 16:02 alenpokos

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

X-Coder264 avatar Apr 05 '19 16:04 X-Coder264