-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Error "It's a requirement to specify a Metadata Driver..." after Upgrade to 4.1.4 #28304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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:
Seems one of these commits is causing this issue: 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 |
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? |
#28366 doesn't fix the issue, If I can, I'll try to provide some context. // 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 |
This PR was merged into the 3.4 branch. Discussion ---------- [DI] Fix dumping some complex service graphs | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28296 (and its duplicates #28355 & #28362 ~+ possibly #28304~) | Lic 8000 ense | MIT | Doc PR | - Commits ------- 769fd4b [DI] Fix dumping some complex service graphs
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 The fix, for now at least, is to 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 |
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:
The constructor injection doesn't work anymore. This is my constructor for the entity listener:
And this is the service configuration:
|
Could you please try #28385 (@hal869 also?) |
OK, now I reproduce the "Too few arguments" error, investigating. |
Thank you 👍 |
So, looking at the code, adding |
Which means this issue is solved. Thank you all for the help! |
This PR was merged into the 3.4 branch. Discussion ---------- [DI] fix dumping lazy services | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28304 | License | MIT | Doc PR | - Commits ------- 7cf1505 [DI] fix dumping lazy services
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 =/
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 |
Can you please confirm this is fixed in |
@nicolas-grekas yes this fixes the problem.. What is the change that was introduced from 4.1.7 to dev that fixes this? |
That one: #29103 |
Well I just ran into this problem when doing the sf 4.1.7 -> 4.1.8. |
This issue is driving me crazy :) |
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. 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. 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? |
I am getting this error after the update from Symfony 5.4.16 to 5.4.17 in the prod environment as long as the proxy-manager-bridge isn't installed. |
Commenting on a closed issue will not help add your comments are likely to get lost. Please open a new issue and provide an example application that allows to reproduce it. |
Uh oh!
There was an error while loading. Please reload this page.
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.Prefetching 41 packages
Package operations: 1 install, 58 updates, 0 removals
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
The text was updated successfully, but these errors were encountered: