Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Symfony 5.2-RC-1 "It's a requirement to specify a Metadata Driver" #39120

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

Closed
eerison opened this issue Nov 19, 2020 · 6 comments
Closed

Symfony 5.2-RC-1 "It's a requirement to specify a Metadata Driver" #39120

eerison opened this issue Nov 19, 2020 · 6 comments

Comments

@eerison
Copy link

eerison commented Nov 19, 2020

Symfony version(s) affected: v5.2.0-RC-1

Description
After migrate symfony 5.1 to 5.2.0-RC-1 I got this error

In ORMException.php line 40:
!!                                                                                 
!!    It's a requirement to specify a Metadata Driver and pass it to Doctrine\ORM  
!!    \Configuration::setMetadataDriverImpl().      

Additional context

symfony/apache-pack                v1.0.1     A pack for Apache support in Symfony
symfony/asset                      v5.2.0-RC1 Symfony Asset Component
symfony/browser-kit                v5.2.0-RC1 Symfony BrowserKit Component
symfony/cache                      v5.2.0-RC1 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            v2.2.0     Generic abstractions related to caching
symfony/config                     v5.2.0-RC1 Symfony Config Component
symfony/console                    v5.2.0-RC1 Symfony Console Component
symfony/css-selector               v5.2.0-RC1 Symfony CssSelector Component
symfony/dependency-injection       v5.2.0-RC1 Symfony DependencyInjection Component
symfony/deprecation-contracts      v2.2.0     A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge            v5.2.0-RC1 Symfony Doctrine Bridge
symfony/dom-crawler                v5.2.0-RC1 Symfony DomCrawler Component
symfony/dotenv                     v5.2.0-RC1 Registers environment variables from a .env file
symfony/error-handler              v5.2.0-RC1 Symfony ErrorHandler Component
symfony/event-dispatcher           v5.2.0-RC1 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v2.2.0     Generic abstractions related to dispatching event
symfony/expression-language        v5.2.0-RC1 Symfony ExpressionLanguage Component
symfony/filesystem                 v5.2.0-RC1 Symfony Filesystem Component
symfony/finder                     v5.2.0-RC1 Symfony Finder Component
symfony/flex                       v1.10.0    Composer plugin for Symfony
symfony/form                       v5.2.0-RC1 Symfony Form Component
symfony/framework-bundle           v5.2.0-RC1 Symfony FrameworkBundle
symfony/http-client                v5.2.0-RC1 Symfony HttpClient component
symfony/http-client-contracts      v2.3.1     Generic abstractions related to HTTP clients
symfony/http-foundation            v5.2.0-RC1 Symfony HttpFoundation Component
symfony/http-kernel                v5.2.0-RC1 Symfony HttpKernel Component
symfony/intl                       v5.2.0-RC1 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/mailer                     v5.2.0-RC1 Symfony Mailer Component
symfony/mailgun-mailer             v5.2.0-RC1 Symfony Mailgun Mailer Bridge
symfony/maker-bundle               v1.23.0    Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing...
symfony/mime                       v5.2.0-RC1 A library to manipulate MIME messages
symfony/monolog-bridge             v5.2.0-RC1 Symfony Monolog Bridge
symfony/monolog-bundle             v3.6.0     Symfony MonologBundle
symfony/options-resolver           v5.2.0-RC1 Symfony OptionsResolver Component
symfony/orm-pack                   v1.2.0     A pack for the Doctrine ORM
symfony/phpunit-bridge             v5.2.0-RC1 Symfony PHPUnit Bridge
symfony/polyfill-intl-grapheme     v1.20.0    Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu          v1.20.0    Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          v1.20.0    Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer   v1.20.0    Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          v1.20.0    Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.20.0    Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             v1.20.0    Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80             v1.20.0    Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-uuid              v1.20.0    Symfony polyfill for uuid functions
symfony/profiler-pack              v1.0.5     A pack for the Symfony web profiler
symfony/property-access            v5.2.0-RC1 Symfony PropertyAccess Component
symfony/property-info              v5.2.0-RC1 Symfony Property Info Component
symfony/routing                    v5.2.0-RC1 Symfony Routing Component
symfony/security-bundle            v5.2.0-RC1 Symfony SecurityBundle
symfony/security-core              v5.2.0-RC1 Symfony Security Component - Core Library
symfony/security-csrf              v5.2.0-RC1 Symfony Security Component - CSRF Library
symfony/security-guard             v5.2.0-RC1 Symfony Security Component - Guard
symfony/security-http              v5.2.0-RC1 Symfony Security Component - HTTP Integration
symfony/service-contracts          v2.2.0     Generic abstractions related to writing services
symfony/stopwatch                  v5.2.0-RC1 Symfony Stopwatch Component
symfony/string                     v5.2.0-RC1 Symfony String component
symfony/test-pack                  v1.0.7     A pack for functional and end-to-end testing within a Symfony app
symfony/translation                v5.2.0-RC1 Symfony Translation Component
symfony/translation-contracts      v2.3.0     Generic abstractions related to translation
symfony/twig-bridge                v5.2.0-RC1 Symfony Twig Bridge
symfony/twig-bundle                v5.2.0-RC1 Symfony TwigBundle
symfony/twig-pack                  v1.0.1     A Twig pack for Symfony projects
symfony/validator                  v5.2.0-RC1 Symfony Validator Component
symfony/var-dumper                 v5.2.0-RC1 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               v5.2.0-RC1 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-profiler-bundle        v5.2.0-RC1 Symfony WebProfilerBundle
symfony/webpack-encore-bundle      v1.8.0     Integration with your Symfony app & Webpack Encore!
symfony/yaml                       v5.2.0-RC1 Symfony Yaml Component

.env

DATABASE_URL="postgres://my_user:123456@host:5432/my_db?serverVersion=13&charset=utf8"

config/packages/doctrine.yaml

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'

        # IMPORTANT: You MUST configure your server version,
        # either here or in the DATABASE_URL env var (see .env file)
        # server_version: '13'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

@eerison eerison added the Bug label Nov 19, 2020
@eerison eerison changed the title Symfony 5.2-RC-1 It's a requirement to specify a Metadata Driver Symfony 5.2-RC-1 "It's a requirement to specify a Metadata Driver" Nov 19, 2020
@jderusse
Copy link
Member

Hello @eerison ,

Could you please share a reproducer or a the project?
Could you also please try with the latest versions 5.2.x-dev version?

@eerison
Copy link
Author

eerison commented Nov 20, 2020

Hello @eerison ,

Could you please share a reproducer or a the project?
Could you also please try with the latest versions 5.2.x-dev version?

Hi @jderusse I'll check today and post here the results.
But I saw that pipelines didn't fail, then I suppose it could be some cache...

shield-wall/myprofile#306
https://app.circleci.com/pipelines/github/eerison/myprofile/355/workflows/24350093-c6b8-4814-8b22-6a32482491a5/jobs/547

@jderusse
Copy link
Member

Thank you for the reproducer. There is a bug in Symfony when generating the container introduced by #38980

The issue in your case is the following:

  • You have a circular reference in services
  • Hopefully the loop is broken thanks to a "lazy" service in the Loop
  • BUT you don't have any Proxy generator
  • In that case, since [DependencyInjection] Fix circular reference with Factory + Lazy Iterrator #38980, symfony ignore the "lazyness" and tries to find a way to dump the container
  • BUT, all your dependencies are injected by constructor
  • Here symfony failed to generate a useful container will all dependency fully built before injecting in the container

It wasn't an issue for YOU before #38980 because at that time, Symfony trusted the lazy service.
But this PR was fixing issue when some services iterate over injected service (#38970) and broke the lazyness.

I'll try to find a way to fix it. Otherwise we should considere reverting #38980

/cc @nicolas-grekas

@eerison
Copy link
Author

eerison commented Nov 21, 2020

FYI: I'm testing with dev and happen the same issue|

root@72736840d99c:/app# composer info symfony/*
symfony/apache-pack                v1.0.1             A pack for Apache support in Symfony
symfony/asset                      5.2.x-dev 19c5971  Symfony Asset Component
symfony/browser-kit                5.2.x-dev 4fc769a  Symfony BrowserKit Component
symfony/cache                      5.2.x-dev c15fd2b  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts            dev-main b1128c0   Generic abstractions related to caching
symfony/config                     5.2.x-dev fa1219e  Symfony Config Component
symfony/console                    5.2.x-dev d1d8b8f  Symfony Console Component
symfony/css-selector               5.2.x-dev b8d8eb0  Symfony CssSelector Component
symfony/dependency-injection       5.2.x-dev d7a2980  Symfony DependencyInjection Component
symfony/deprecation-contracts      dev-main be5a366   A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge            5.2.x-dev de2c71f  Symfony Doctrine Bridge
symfony/dom-crawler                5.2.x-dev 0969122  Symfony DomCrawler Component
symfony/dotenv                     5.2.x-dev 264ca18  Registers environment variables from a .env file
symfony/error-handler              5.2.x-dev 289008c  Symfony ErrorHandler Component
symfony/event-dispatcher           5.2.x-dev aa13a09  Symfony EventDispatcher Component
symfony/event-dispatcher-contracts dev-main 8e3016b   Generic abstractions related to dispatching event
symfony/expression-language        5.2.x-dev 6fca724  Symfony ExpressionLanguage Component
symfony/filesystem                 5.2.x-dev bb92ba7  Symfony Filesystem Component
symfony/finder                     5.2.x-dev fd83055  Symfony Finder Component
symfony/flex                       v1.10.0            Composer plugin for Symfony
symfony/form                       5.2.x-dev 6327575  Symfony Form Component
symfony/framework-bundle           5.2.x-dev a82f301  Symfony FrameworkBundle
symfony/http-client                5.2.x-dev dda8496  Symfony HttpClient component
symfony/http-client-contracts      dev-main 41db680   Generic abstractions related to HTTP clients
symfony/http-foundation            5.2.x-dev ba0aeb1  Symfony HttpFoundation Component
symfony/http-kernel                5.2.x-dev cc38260  Symfony HttpKernel Component
symfony/intl                       5.2.x-dev eaac169  A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/mailer                     5.2.x-dev f30fe13  Symfony Mailer Component
symfony/mailgun-mailer             5.2.x-dev 0b42d96  Symfony Mailgun Mailer Bridge
symfony/maker-bundle               v1.23.0            Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about...
symfony/mime                       5.2.x-dev 05f667e  A library to manipulate MIME messages
symfony/monolog-bridge             5.2.x-dev 6634bc5  Symfony Monolog Bridge
symfony/monolog-bundle             dev-master a5b28e1 Symfony MonologBundle
symfony/options-resolver           5.2.x-dev 87a2a4a  Symfony OptionsResolver Component
symfony/orm-pack                   v1.2.0             A pack for the Doctrine ORM
symfony/phpunit-bridge             5.x-dev 9604850    Symfony PHPUnit Bridge
symfony/polyfill-intl-grapheme     dev-main be09274   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu          dev-main 94bafdb   Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn          dev-main 4c489fd   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer   dev-main 69609f9   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          dev-main 401c9d9   Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             dev-main 4a4465f   Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73             dev-main 8c0d39c   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80             dev-main 3a11f3d   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-uuid              dev-main ad94768   Symfony polyfill for uuid functions
symfony/profiler-pack              v1.0.5             A pack for the Symfony web profiler
symfony/property-access            5.2.x-dev 5cf8676  Symfony PropertyAccess Component
symfony/property-info              5.2.x-dev 69ca096  Symfony Property Info Component
symfony/routing                    5.2.x-dev 1e61976  Symfony Routing Component
symfony/security-bundle            5.2.x-dev 1baf1c3  Symfony SecurityBundle
symfony/security-core              5.2.x-dev ed0de5b  Symfony Security Component - Core Library
symfony/security-csrf              5.2.x-dev d98a521  Symfony Security Component - CSRF Library
symfony/security-guard             5.2.x-dev 63d71a7  Symfony Security Component - Guard
symfony/security-http              5.2.x-dev b137f9a  Symfony Security Component - HTTP Integration
symfony/service-contracts          dev-main 0aeee2f   Generic abstractions related to writing services
symfony/stopwatch                  5.2.x-dev 2b105c0  Symfony Stopwatch Component
symfony/string                     5.2.x-dev 40e975e  Symfony String component
symfony/test-pack                  v1.0.7             A pack for functional and end-to-end testing within a Symfony app
symfony/translation                5.2.x-dev 331974a  Symfony Translation Component
symfony/translation-contracts      dev-main 5d449c8   Generic abstractions related to translation
symfony/twig-bridge                5.2.x-dev 8daf9ed  Symfony Twig Bridge
symfony/twig-bundle                5.2.x-dev 954b642  Symfony TwigBundle
symfony/twig-pack                  v1.0.1             A Twig pack for Symfony projects
symfony/validator                  5.2.x-dev 9919be5  Symfony Validator Component
symfony/var-dumper                 5.2.x-dev b75af2f  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter               5.2.x-dev fbc3507  A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-profiler-bundle        5.2.x-dev a1f3f17  Symfony WebProfilerBundle
symfony/webpack-encore-bundle      v1.8.0             Integration with your Symfony app & Webpack Encore!
symfony/yaml                       5.2.x-dev 1e18203  Symfony Yaml Component

@eerison
Copy link
Author

eerison commented Nov 21, 2020

I installed composer require symfony/proxy-manager-bridge and it works 😃

@jderusse
Copy link
Member

The fix has not been merged yet. (but you can try my patch and provide a feedback on the PR, Whether or not it fux your issue).

Yeah installing a proxy is a workaround for this issue.

nicolas-grekas added a commit that referenced this issue Nov 27, 2020
…truct loop (jderusse)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] Fix circular in DI with lazy + byContruct loop

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39120
| License       | MIT
| Doc PR        | -

This fix another issue lazy service.
It partially revert #38980 and #39021

Initially, we trusted lazy services to be lazy and not beeing called while building the services graph
=> bug #38970 when lazy deps is injected in a factory, it may be consumed directly to build the object before the graph is fully built
Fixed by #38980 => lazy service are considered as "normal service"
=> bug #39015 some loop are not resolvable with "normal service", but it shouldn't be an issue when servie proxifyied
Fixed by #39021 => lazy service are considered as "normal service" except when proxyfied
=> bug #39120 some loop are not resolvable with "normal service", but it shouldn't be an issue because the lazy service is injected in the constructor and user

Fixed by this PR => that revert to the initial state. lazy service are trusted.
But now, The IterratorArgument injected in a factory (single exception) is not more considered as lazy

Commits
-------

54af139 [DependencyInjection] Fix circular in DI with lazy + byContruct loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants