Description
Symfony version(s) affected: 4.1.10, maybe others
Description
Recent upgrade from v4.1.7 to v4.1.10 causes issue with autowiring of custom doctrine repositories created using code explained at https://symfony.com/doc/4.1/doctrine.html#querying-for-objects-the-repository
Exception thrown:
Argument 1 passed to App\Repository\CouponRepository::__construct() must implement interface Symfony\Bridge\Doctrine\RegistryInterface, instance of Doctrine\ORM\EntityManager given, called in vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php on line 68
How to reproduce
Application repository __construct() arguments are ignored and EntityManager is forcibly injected for all repository services.
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* Class CouponRepository
* @package App\Repository
*/
class CouponRepository extends AbstractRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Coupon::class);
}
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
/**
* Class AbstractRepository
* @package App\Repository\Common
*/
abstract class AbstractRepository extends ServiceEntityRepository
{
This is happening even if I manually wire repository with ManagerRegistry service as argument.
Possible Solution
I did not find any solution yet, also haven't figure out which PR caused this behavior - maybe somebody else will have time to investigate. I had to downgrade symfony/dependency-injection package to the previously working one (v4.1.8).