Symfony version(s) affected: 4.1.4
Description
After Upgrade from 4.1.3 to 4.1.4 i get the following error:
It's a requirement to specify a Metadata Driver and pass it to Doctrine\ORM\Configuration::setMetadataDriverImpl().
EDIT: if you still have this issue, running composer require symfony/proxy-manager-bridge
should fix it.
Trace:
in聽ORMException.php聽line 38
--
at聽ORMException::missingMappingDriverImpl()in聽EntityManager.php聽line 845
at聽EntityManager::create(object(Connection),聽object(Configuration))in聽srcDevDebugProjectContainer.php聽line 698
at聽srcDevDebugProjectContainer->getDoctrine_Orm_DefaultEntityManagerService()in聽Container.php聽line 242
at聽Container->make('doctrine.orm.default_entity_manager', 1)in聽Container.php聽line 222
at聽Container->get('doctrine.orm.default_entity_manager')in聽ManagerRegistry.php聽line 35
at聽ManagerRegistry->getService('doctrine.orm.default_entity_manager')in聽AbstractManagerRegistry.php聽line 200
at聽AbstractManagerRegistry->getManagers()in聽ProxyCacheWarmer.php聽line 49
at聽ProxyCacheWarmer->warmUp('E:\\www\\ltgsc\\var\\cache\\dev')in聽CacheWarmerAggregate.php聽line 57
at聽CacheWarmerAggregate->warmUp('E:\\www\\ltgsc\\var\\cache\\dev')in聽Kernel.php聽line 562
at聽Kernel->initializeContainer()in聽Kernel.php聽line 123
at聽Kernel->boot()in聽Kernel.php聽line 183
at聽Kernel->handle(object(Request))in聽index.php聽line 34
````
To be updated:
composer outdated --direct
friendsofphp/php-cs-fixer v2.12.2 v2.13.0 A tool to automatically fix PHP code style
symfony/browser-kit v4.1.3 v4.1.4 Symfony BrowserKit Component
symfony/console v4.1.3 v4.1.4 Symfony Console Component
symfony/css-selector v4.1.3 v4.1.4 Symfony CssSelector Component
symfony/debug-bundle v4.1.3 v4.1.4 Symfony DebugBundle
symfony/dotenv v4.1.3 v4.1.4 Registers environment variables from a .env file
symfony/expression-language v4.1.3 v4.1.4 Symfony ExpressionLanguage Component
symfony/flex v1.0.89 v1.1.0 Composer plugin for Symfony
symfony/form v4.1.3 v4.1.4 Symfony Form Component
symfony/framework-bundle v4.1.3 v4.1.4 Symfony FrameworkBundle
symfony/lock v4.1.3 v4.1.4 Symfony Lock Component
symfony/maker-bundle v1.5.0 v1.6.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/phpunit-bridge v4.1.3 v4.1.4 Symfony PHPUnit Bridge
symfony/polyfill-apcu v1.8.0 v1.9.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/security-bundle v4.1.3 v4.1.4 Symfony SecurityBundle
symfony/templating v4.1.3 v4.1.4 Symfony Templating Component
symfony/translation v4.1.3 v4.1.4 Symfony Translation Component
symfony/validator v4.1.3 v4.1.4 Symfony Validator Component
symfony/var-dumper v4.1.3 v4.1.4 Symfony mechanism for exploring and dumping PHP variables
symfony/web-server-bundle v4.1.3 v4.1.4 Symfony WebServerBundle
symfony/yaml v4.1.3 v4.1.4 Symfony Yaml Component
Update:
composer update && composer dump-autoload --optimize
Loading composer repositories with package information Updating dependencies (including require-dev)
Prefetching 41 packages
Package operations: 1 install, 58 updates, 0 removals
My Doctrine Config:
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8
# With Symfony 3.3, remove the `resolve:` prefix
url: '%env(DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
XXXX:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'XXXX\Entity'
alias: XXXX
```
I can confirm this issue after upgrading from Symfony 3.4.14 to 3.4.15.
Also had same trouble while upgrading from 4.1.3 to 4.1.4.
Can one of you create a small example application that allows to reproduce?
It happens on a bigger closed source project, i am working on. I'm currently trying to figure out the cause by updating each package individually. I hope to be able to give more details soon.
Done the updates step by step on this project and after doing this particular update the error occures:
composer update symfony/dependency-injection
Loading composer repositories with package information Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating symfony/dependency-injection (v4.1.3 => v4.1.4): Loading from cache
Seems one of these commits is causing this issue:
https://github.com/symfony/dependency-injection/compare/v4.1.3...v4.1.4
I investigate further.
+1 Confirming that downgrading the dependency injection package to 4.1.3 resolved the issue.
I had exactly the same error while upgrading Symfony 3.4.13 to 3.4.15. When disabling doctrine tag "doctrine.orm.entity_listener" on the services that used it, there's no more errors (not a solution but a diagnose). In my case cache:clear failed and the entire project is broken so i'm staying in 3.4.13.
Can anyone provide a reproducer, and maybe also find the commit which introduced this?
Does composer require symfony/proxy-manager-bridge
fix the issue?
For me it's also the "doctrine.orm.entity_listener" from 2 doctrine event listener i use. After commenting them out it works (also not a solution but a diagnose).
And yes, with suggested "symfony/proxy-manager-bridge" it works (with doctrine event listener).
Will try to build a small reproducer.
Can you please report if applying #28366 fixes your issue?
// var/cache/local/ContainerH1kverd/appLocalDebugProjectContainer.php
/**
* Gets the public 'doctrine.orm.my_entity_manager' shared service.
*
* @return \Doctrine\ORM\EntityManager
*/
protected function getDoctrine_Orm_MyEntityManagerService($lazyLoad = true)
{
$a = new \Doctrine\ORM\Configuration();
$this->services['doctrine.orm.my_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create(${($_ = isset($this->services['doctrine.dbal.default_connection']) ? $this->services['doctrine.dbal.default_connection'] : $this->getDoctrine_Dbal_DefaultConnectionService()) && false ?: '_'}, $a);
$b = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array(($this->targetDirs[3].'/vendor/sonata-project/media-bundle/src/Resources/config/doctrine') => 'Sonata\\MediaBundle\\Entity', ($this->targetDirs[3].'/vendor/sonata-project/user-bundle/src/Resources/config/doctrine') => 'Sonata\\UserBundle\\Entity'));
$b->setGlobalBasename('mapping');
$c = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(${($_ = isset($this->services['annotation_reader']) ? $this->services['annotation_reader'] : $this->getAnnotationReaderService()) && false ?: '_'}, array(0 => ($this->targetDirs[3].'/vendor/gesdinet/jwt-refresh-token-bundle/Entity'), 1 => ($this->targetDirs[3].'/vendor/hackzilla/ticket-bundle/Entity')));
$d = new \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver(array(($this->targetDirs[3].'/src/MyBundle/Resources/config/doctrine') => 'MyBundle\\Entity'));
$d->setGlobalBasename('mapping');
$e = new \Doctrine\ORM\Mapping\Driver\YamlDriver(new \Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator(array(($this->targetDirs[3].'/vendor/gesdinet/jwt-refresh-token-bundle/Resources/config/doctrine-orm') => 'Gesdinet\\JWTRefreshTokenBundle\\Entity', ($this->targetDirs[3].'/vendor/gesdinet/jwt-refresh-token-bundle/Resources/config/doctrine-entity') => 'Gesdinet\\JWTRefreshTokenBundle\\Entity'), '.orm.yml'));
$f = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
$f->addDriver($b, 'Sonata\\MediaBundle\\Entity');
$f->addDriver($b, 'Sonata\\UserBundle\\Entity');
$f->addDriver($c, 'Gesdinet\\JWTRefreshTokenBundle\\Entity');
$f->addDriver($c, 'Hackzilla\\Bundle\\TicketBundle\\Entity');
$f->addDriver($d, 'MyBundle\\Entity');
$f->addDriver(new \Doctrine\ORM\Mapping\Driver\XmlDriver(new \Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator(array(($this->targetDirs[3].'/vendor/friendsofsymfony/user-bundle/Resources/config/doctrine-mapping') => 'FOS\\UserBundle\\Model'), '.orm.xml')), 'FOS\\UserBundle\\Model');
$f->addDriver($e, 'Gesdinet\\JWTRefreshTokenBundle\\Entity');
$f->addDriver($e, 'Gesdinet\\JWTRefreshTokenBundle\\Entity');
$a->setEntityNamespaces(array('SonataMediaBundle' => 'Sonata\\MediaBundle\\Entity', 'SonataUserBundle' => 'Sonata\\UserBundle\\Entity', 'GesdinetJWTRefreshTokenBundle' => 'Gesdinet\\JWTRefreshTokenBundle\\Entity', 'HackzillaTicketBundle' => 'Hackzilla\\Bundle\\TicketBundle\\Entity', 'MyBundle' => 'MyBundle\\Entity'));
$a->setMetadataCacheImpl(${($_ = isset($this->services['doctrine_cache.providers.doctrine.orm.my_metadata_cache']) ? $this->services['doctrine_cache.providers.doctrine.orm.my_metadata_cache'] : $this->getDoctrineCache_Providers_Doctrine_Orm_MyMetadataCacheService()) && false ?: '_'});
$a->setQueryCacheImpl(${($_ = isset($this->services['doctrine_cache.providers.doctrine.orm.my_query_cache']) ? $this->services['doctrine_cache.providers.doctrine.orm.my_query_cache'] : $this->getDoctrineCache_Providers_Doctrine_Orm_MyQueryCacheService()) && false ?: '_'});
$a->setResultCacheImpl(${($_ = isset($this->services['doctrine_cache.providers.doctrine.orm.my_result_cache']) ? $this->services['doctrine_cache.providers.doctrine.orm.my_result_cache'] : $this->getDoctrineCache_Providers_Doctrine_Orm_MyResultCacheService()) && false ?: '_'});
$a->setMetadataDriverImpl($f);
$a->setProxyDir(($this->targetDirs[0].'/doctrine/orm/Proxies'));
$a->setProxyNamespace('Proxies');
$a->setAutoGenerateProxyClasses(false);
$a->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
$a->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
$a->setNamingStrategy(new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy());
$a->setQuoteStrategy(new \Doctrine\ORM\Mapping\DefaultQuoteStrategy());
$a->setEntityListenerResolver(${($_ = isset($this->services['doctrine.orm.my_entity_listener_resolver']) ? $this->services['doctrine.orm.my_entity_listener_resolver'] : $this->getDoctrine_Orm_MyEntityListenerResolverService()) && false ?: '_'});
$a->setRepositoryFactory(new \Doctrine\Bundle\DoctrineBundle\Repository\ContainerRepositoryFactory(new \Symfony\Component\DependencyInjection\ServiceLocator(array())));
$a->addCustomStringFunction('sha2', 'DoctrineExtensions\\Query\\Mysql\\Sha2');
$a->addCustomStringFunction('group_concat', 'DoctrineExtensions\\Query\\Mysql\\GroupConcat');
$a->addCustomStringFunction('substring_index', 'DoctrineExtensions\\Query\\Mysql\\SubstringIndex');
$a->addCustomDatetimeFunction('timestampdiff', 'DoctrineExtensions\\Query\\Mysql\\TimestampDiff');
$a->addFilter('softdeleteable', 'Gedmo\\SoftDeleteable\\Filter\\SoftDeleteableFilter');
$a->addFilter('my_filter', 'MyBundle\\Doctrine\\MyFilter');
${($_ = isset($this->services['doctrine.orm.my_manager_configurator']) ? $this->services['doctrine.orm.my_manager_configurator'] : $this->services['doctrine.orm.my_manager_configurator'] = new \Doctrine\Bundle\DoctrineBundle\ManagerConfigurator(array(0 => 'softdeleteable', 1 => 'my_filter'), array())) && false ?: '_'}->configure($instance);
return $instance;
}
I left some context from appLocalDebugProjectContainer
at https://github.com/symfony/symfony/issues/28304#issuecomment-418521487.
I think I now understand where the issue comes from. It's unrelated to #28366 indeed. The issue is that in some situations, in order to resolve some circular loops, we call setters on inline services after injecting them into their consumer. This doesn't play well with runtime checks like the one done in EntityManager
.
The fix, for now at least, is to composer require symfony/proxy-manager-bridge
, because the situation I'm referring to happens only when this package is not installed (installing it enables some superpower of the DI container, namely to instantiate some services lazily - you definitely want it on real world apps.)
I fear a real fix might be out of reach for 3.4/4.1 but I'll have a better look.
Ok, this solution works for me. Thank you for taking care of this problem.
Confirmed, thank you!
I can confirm adding dependency for symfony/proxy-manager-bridge
also fixes this https://github.com/symfony/symfony/issues/26778#issuecomment-378947283.
I'm reopening to keep track of the issue. I've a local reproducer where the reordering leads to a fatal error.
Is ok, since for me, it seems there is another issue (these comes only, when the listener is used, the issue above was on every page even when the listener was not used): After upgrading symfony/dependency-injection to 4.1.4 and installing symfony/proxy-manager-bridge i got the following error with my listener:
Too few arguments to function XXX\EventListener\EntityListener::__construct(), 0 passed in \vendor\doctrine\doctrine-bundle\Mapping\ContainerAwareEntityListenerResolver.php on line 76 and exactly 3 expected
at src\EventListener\EntityListener.php:26
at XXX\EventListener\EntityListener->__construct()
(vendor\doctrine\doctrine-bundle\Mapping\ContainerAwareEntityListenerResolver.php:76)
at Doctrine\Bundle\DoctrineBundle\Mapping\ContainerAwareEntityListenerResolver->resolve('LTGSC\\EventListener\\RmaEntityListener')
(vendor\doctrine\orm\lib\Doctrine\ORM\Event\ListenersInvoker.php:110)
at Doctrine\ORM\Event\ListenersInvoker->invoke(object(ClassMetadata), 'preUpdate', object(Rma), object(PreUpdateEventArgs), 7)
(vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php:1151)
at Doctrine\ORM\UnitOfWork->executeUpdates(object(ClassMetadata))
(vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php:392)
at Doctrine\ORM\UnitOfWork->commit(null)
(vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php:359)
at Doctrine\ORM\EntityManager->flush(null)
(var\cache\dev\Container2Y6TS4n\EntityManager_9a5be93.php:125)
at EntityManager_9a5be93->flush()
(src\Controller\ExportController.php:40)
at XXX\Controller\ExportController->exportServiceReportAction(object(RmaProduct), object(Request), object(EntityManager_9a5be93), object(Serializer))
(vendor\symfony\http-kernel\HttpKernel.php:149)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor\symfony\http-kernel\HttpKernel.php:66)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor\symfony\http-kernel\Kernel.php:188)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public\index.php:34)
The constructor injection doesn't work anymore.
This is my constructor for the entity listener:
use XXX\DependencyInjection\Mail;
use XXX\Entity\XXX;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Symfony\Component\Translation\TranslatorInterface;
public function __construct(Mail $mail, TranslatorInterface $translator, $config)
{
$this->mail = $mail;
$this->translator = $translator;
$this->config = $config;
}
And this is the service configuration:
XXX\EventListener\EntityListener:
lazy: true
arguments:
$config: '%mail%'
tags:
- { name: "doctrine.orm.entity_listener", entity: XXX\Entity\XXX, event: preUpdate }
Could you please try #28385 (@hal869 also?)
proxy-manager shouldn't be needed anymore to work around the issue.
@nicolas-grekas
composer show | egrep "dependency-injection|proxy-manager-bridge"
symfony/dependency-injection v4.1.4 Symfony DependencyInjectio...
composer update
...
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In PhpDumper.php line 1543:
!!
!! Cannot dump definitions which have method calls.
!!
!!
!!
Script @auto-scripts was called via post-update-cmd
git remote add nicolas-grekas-di-fix https://github.com/nicolas-grekas/symfony
git fetch nicolas-grekas-di-fix
git cherry-pick ccb6e1b5bfde8216f20b9b5026269c5fa59b39e2
composer update
...
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In FileLoader.php line 168:
!!
!! The autoloader expected class "App\Symfony\Component\DependencyInjection\Du
!! mper\PhpDumper" to be defined in file "/dev/www/test/vendor/compo
!! ser/../../src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php".
!! The file was found but the class was not in it, the class name or namespace
!! probably has a typo in /dev/www/test/config/services.yaml (which
!! is loaded in resource "/dev/www/test/config/services.yaml").
!!
!!
!! In DebugClassLoader.php line 288:
!!
!! The autoloader expected class "App\Symfony\Component\DependencyInjection\Du
!! mper\PhpDumper" to be defined in file "/dev/www/test/vendor/compo
!! ser/../../src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php".
!! The file was found but the class was not in it, the class name or namespace
!! probably has a typo.
!!
!!
!!
Same as before @hal869, that's not how the patch should be applied. Note that the reproducer you gave to me is fixed for me.
Will try next week, having problems aplying this patch under windows.
@nicolas-grekas
that's not how the patch should be applied.
ok. then, what _is_ the correct method?
can't 'simply' update to 4.1@dev, yet, as #28385 is closed, but not merged ...
This is now merged in 3.4, 4.1 and master, please report back if you still experience any issue. You should be able to remove proxy-manager-bridge if you didn't need it before.
@nicolas-grekas The issue is still present when the resource is a directory. cf configuration below:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\Listener\Entity\:
resource: '../src/Listener/Entity'
tags:
- { name: doctrine.orm.entity_listener }
App\Listener\Entity\MediaEntityListener:
tags:
- { name: doctrine.orm.entity_listener, priority: 100 }
It's working when i comment the App\Listener\Entity\ service declaration and keep MediaEntityListener.
It's ok with the proxy-manager-bridge also.
What's the best way to get this piece of code in an symfony 4.1.4 installation to get it tested?
since it's merged now, you can just require ~4.1.6@dev
(and maybe also set minimum-stability: dev)
Ok, done this, but the error persists.
Unlike @Laulibrius i get the error also with this config:
(Commented to services out for testing, but error still exists)
services:
_defaults:
autowire: true
autoconfigure: true
public: false
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
XXXX\EventListener\:
resource: '../src/EventListener/*'
# XXXX\EventListener\DoctrineEventListener:
# tags:
# - { name: doctrine.event_listener, event: onFlush }
# XXXX\EventListener\XXXXEntityListener:
# lazy: true
# arguments:
# $config: '%mail%'
# tags:
# - { name: "doctrine.orm.entity_listener", entity: XXXX\Entity\XXXX, event: preUpdate }
#
XXXX\EventListener\XXXXEntityListener:
lazy: true
arguments:
$config: '%mail%'
tags:
- { name: "doctrine.orm.entity_listener", entity: XXXX\Entity\XXXX, event: preUpdate }
And it works if you add proxy-manager-bridge again? Note that lazy=true does nothing if you don't have it installed.
I'd need a reproducer to understand if you can provide one.
@nicolas-grekas New minimal reproducer : https://github.com/elementaire/sf4-di-eventsubscriber
For example, I've just injected the (Doctrine/Dbal) Connection in a (Doctrine) EventSubscriber and obtain "Cannot dump definitions which have method calls.".
I have the same behaviour as described above: Without proxy-manager-bridge i got the error as discribed in first post on all pages. With proxy-manager-bridge installed, pages that don't make use of an listener, works, but when listener are used i get the error descibed in this post: https://github.com/symfony/symfony/issues/28304#issuecomment-418983913
Now I have removed lazy=true, from my listeners and with proxy-manager-bridge installed it works.
@elementaire thank you for the reproducer. I tried it with "symfony/dependency-injection": "~4.1.5@dev"
and the issue your repo hits is fixed already there.
@ThomasTr I would really appreciate a reproducer also.
@nicolas-grekas Actually trying to build a reproducer the third time (seems i always stripped to much out at once so i can't reproduce it).
I have several other services injected in my Entity Listeners Constructor and get the error "It's a requirement to specify a Metadata Driver..." with "symfony/dependency-injection": "~4.1.6@dev" but without proxy-manager-bridge.
/**
* EntityListener constructor.
*
* @param Mail $mail
* @param TranslatorInterface $translator
* @param array $config
*/
public function __construct(Mail $mail, TranslatorInterface $translator, $config)
{
$this->mail = $mail;
$this->translator = $translator;
$this->config = $config;
}
When i strip out theses services from my listeners constructor, the error goes away.
Will try to provide an reporducer next week.
Ok, managed to build an reproducer: https://github.com/ThomasTr/reproducer
You get on every page the error "It's a requirement to specify a Metadata Driver..."
After installing Proxy-Manager-Bridge (which was not necessary before) you get the error
"Too few arguments to function App\EventListenerEntityListener::__construct(), 0 passed"
After removing the line lazy:true from the listener in event_listener.yaml it seems to work.
I compared the compiled containers in my app (as i wasnt able to easily create a minimal reproducer out of it).
Basically if i move
$this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($a, $b);
back to the bottom in getDoctrine_Orm_DefaultEntityManagerService
, which it was before at, it starts working again.
Thanks for the hints, I'll check that asap.
Should be fixed by #28507, please confirm @ThomasTr @ro0NL (a big thanks for the reproducer.)
"Too few arguments to function App\EventListenerEntityListener::__construct(), 0 passed"
Note that I don't reproduce this when adding the bridge as there is no EntityListener
in the reproducer.
Might be an issue with the configuration maybe, thus unrelated to this issue?
Note that I don't reproduce this when adding the bridge as there is no
EntityListener
in the reproducer.
Might be an issue with the configuration maybe, thus unrelated to this issue?
Mmh, here is the listener: https://github.com/ThomasTr/reproducer/blob/master/src/EventListener/ProductEntityListener.php
Configured here https://github.com/ThomasTr/reproducer/blob/master/config/event_listener.yaml as listner for the preUpdate event for App\Entity\Product
The entity update is done in the commentAction in the HomepageController.
Activate lazy: true (currently commented) in event_listener.yaml and install proxy-manager-bridge.
Then when you call the url /comment you should get the error:
"Too few arguments to function App\EventListenerEntityListener::__construct(), 0 passed"
Looks like I'm missing a DB now. Anyway, can you check all these behaviors disappear when applying the patch on PhpDumper.php
like in #28507?
OK, now I reproduce the "Too few arguments" error, investigating.
Thank you 馃憤
So, looking at the code, adding lazy: true
is not supported by doctrine-bundle. The reason is that its ContainerAwareEntityListenerResolver
uses get_class()
, which doesn't work on lazy proxies.
Instead, "lazy" should be set on the tag (not on the definition itself.)
Might be worth an issue on doctrine-bundle.
Which means this issue is solved. Thank you all for the help!
Looks like I'm missing a DB now. Anyway, can you check all these behaviors disappear when applying the patch on
PhpDumper.php
like in #28507?
Seems to work for my issue: don't get the error "It's a requirement to specify a Metadata Driver..." without the proxy-manager-bridge anymore
Had the same issue on SF 4.1.4... Works for me too after upgrade to SF4.1.6.
Any chance this happens again in 4.2 =/
It's a requirement to specify a Metadata Driver and pass it to Doctrine\ORM\Configuration::setMetadataDriverImpl().
getDoctrine_Orm_DefaultEntityManagerService.php
<?php
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
// Returns the public 'doctrine.orm.default_entity_manager' shared service.
include_once $this->targetDirs[3].'/vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/ObjectManager.php';
// ...
$a = new \Doctrine\ORM\Configuration();
$this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create(($this->services['doctrine.dbal.default_connection'] ?? $this->load('getDoctrine_Dbal_DefaultConnectionService.php')), $a);
$b = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
$c = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array(($this->targetDirs[0].'/msgphp/doctrine-mapping') => 'MsgPhp'));
$c->setGlobalBasename('mapping');
$b->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(($this->privates['annotations.cached_reader'] ?? $this->load('getAnnotations_CachedReaderService.php')), array(0 => ($this->targetDirs[3].'/src/Entity'))), 'App\\Entity');
//..
$a->setMetadataDriverImpl($b);
//...
(new \Doctrine\Bundle\DoctrineBundle\ManagerConfigurator(array(), array()))->configure($instance);
return $instance;
I have the same issue when I switch my env from dev to prod
doctrine/doctrine-bundle 1.9.1
symfony version: v4.1.7
Can you please confirm this is fixed in 4.1@dev
version?
@nicolas-grekas yes this fixes the problem.. What is the change that was introduced from 4.1.7 to dev that fixes this?
Well I just ran into this problem when doing the sf 4.1.7 -> 4.1.8.
composer require symfony/proxy-manager-bridge
fixed it, but it's another direct unneeded dependency ;)
This issue is driving me crazy :)
I absolutely need a reproducer please.
I just checked on a personal project but since I updated to Symfony 4.1.8,
I cannot reproduce this bug... Everything works fine now. Sorry @nicolas-grekas, I
cannot help you on this one :(
@kissifrot fixed!
@nicolas-grekas Yay! What was the problem?
Doctrine bundle defining a Configuration object as a service and forcing a specific way to dump it. Complex issue :)
I'm getting the same error when updating from 3.4.18 to 3.4.19.
I'm getting the same error with symfony 5.0.8.
This error is mainly thrown if i use console commands. In the shutdown function of the doctrine bundle the entity Manager is injected as proxy.
If it than calls the clear method the error is thrown when the proxy is trying to instantiate the entityManager.
The $this->container->get($id) returns a proxy.
I'm using the proxy-manager-bridge.
Actual I'm decorating the EntityManager with my own factorymethod to prevent it from beeing lazy.
Is there any config option I'm missing or is this unwanted behaviour?
Can't reproduce it with a fresh system.
Most helpful comment
Done the updates step by step on this project and after doing this particular update the error occures:
Seems one of these commits is causing this issue:
https://github.com/symfony/dependency-injection/compare/v4.1.3...v4.1.4
I investigate further.