You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sylius version affected: 1.11-1.14 I didn't check 2.0 but on 1.13 branch the problem still exists.
Description
If Resource doesn't have custom repository class it uses EntityRepository and in src/Bundle/DependencyInjection/Driver/Doctrine/DoctrineORMDriver.php:63 the repository is created by executing getRepository on EntityManager class and inside that method, the repository is given $this refering to EntityManager, so instead of holding the proxy it holds object directly, which then creates issue if you wanna use ManagerRegistry to reset the EntityManager.
But if you look into else of the if in the mentioned file, if resource is using custom repository class, it's using $definition->setArguments([$managerReference, $this->getClassMetadataDefinition($metadata)]);, which will give it the EntityManager proxy which works with ManagerRegistry.
Steps to reproduce
Any repository that uses EntityRepository has EntityManager object instead of Proxy.
Possible Solution
Simplest solution would be not to use the factory but create the repository in the same way as it is done in the else statement aka
Sylius version affected: 1.11-1.14 I didn't check 2.0 but on 1.13 branch the problem still exists.
Description
If Resource doesn't have custom repository class it uses
EntityRepository
and insrc/Bundle/DependencyInjection/Driver/Doctrine/DoctrineORMDriver.php:63
the repository is created by executinggetRepository
onEntityManager
class and inside that method, the repository is given$this
refering toEntityManager
, so instead of holding the proxy it holds object directly, which then creates issue if you wanna useManagerRegistry
to reset theEntityManager
.But if you look into
else
of the if in the mentioned file, if resource is using custom repository class, it's using$definition->setArguments([$managerReference, $this->getClassMetadataDefinition($metadata)]);
, which will give it theEntityManager
proxy which works withManagerRegistry
.Steps to reproduce
Any repository that uses
EntityRepository
hasEntityManager
object instead of Proxy.Possible Solution
Simplest solution would be not to use the factory but create the repository in the same way as it is done in the
else
statement akareplace
with
and it works just fine.
The text was updated successfully, but these errors were encountered: