Skip to content
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

Debug command for doctrine always return the default values #28016

Closed
sir-kain opened this issue Jul 20, 2018 · 7 comments
Closed

Debug command for doctrine always return the default values #28016

sir-kain opened this issue Jul 20, 2018 · 7 comments

Comments

@sir-kain
Copy link
Contributor

Symfony version(s) affected: 4.*

Description
First, set your DATABASE_URL from .env or phpunit.xml file
Then execute the following command:
bin/console debug:config doctrine
or bin/console debug:config doctrine --env=test

The output will not return the conform host, user, password parameters:

waly@waly:/var/www/html/sf4$ php bin/console debug:config doctrine

Current configuration for extension with alias "doctrine"
=========================================================

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver: pdo_mysql
                server_version: '5.7'
                charset: utf8mb4
                default_table_options:
                    charset: utf8mb4
                    collate: utf8mb4_unicode_ci
                url: '%env(resolve:DATABASE_URL)%'
                host: localhost
                port: null
                user: root
                password: null
                logging: true
                profiling: true
                options: {  }
                mapping_types: {  }
                slaves: {  }
                shards: {  }
        types: {  }
    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: default
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore
                auto_mapping: true
                mappings:
                    App:
                        is_bundle: false
                        type: annotation
                        dir: /var/www/html/sf4/src/Entity
                        prefix: App\Entity
                        alias: App
                        mapping: true
                query_cache_driver:
                    type: array
                    namespace: null
                    cache_provider: null
                metadata_cache_driver:
                    type: array
                    namespace: null
                    cache_provider: null
                result_cache_driver:
                    type: array
                    namespace: null
                    cache_provider: null
                class_metadata_factory_name: Doctrine\ORM\Mapping\ClassMetadataFactory
                default_repository_class: Doctrine\ORM\EntityRepository
                quote_strategy: doctrine.orm.quote_strategy.default
                entity_listener_resolver: null
                repository_factory: doctrine.orm.container_repository_factory
                hydrators: {  }
                filters: {  }
        proxy_dir: /var/www/html/sf4/var/cache/dev/doctrine/orm/Proxies
        proxy_namespace: Proxies
        resolve_target_entities: {  }

However, on version 3.4 or lower the command returns the values passed from the parameters.yml file

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver: pdo_mysql
                host: 127.0.0.1
                port: null
                dbname: mybdd
                user: root
                password: passer
                charset: UTF8
                server_version: 5.5.60
                logging: true
                profiling: true
                options: {  }
                mapping_types: {  }
                default_table_options: {  }
                slaves: {  }
                shards: {  }
@stof
Copy link
Member

stof commented Jul 20, 2018

well, that's actually logical. The url is not parsed at the config level, but by DBAL itself at the time of creating the Connection object (and this is precisely why using an environment variable accessed at runtime works for this param)

@sir-kain
Copy link
Contributor Author

It would be interesting to alert the developer in this case.
Because I spent a lot of time re-editing my .env file because the command sent me wrong data

@ro0NL
Copy link
Contributor

ro0NL commented Jul 20, 2018

It would be interesting to alert the developer in this case.

What case exactly? This is by design from Doctrine's point of view; you either configure a url, or a host/user/pass/db combination.

@stof
Copy link
Member

stof commented Jul 20, 2018

actually, you can even mix both. If your URL does not provide a username or password, the one configured explicitly will still be used for instance.

@ro0NL
Copy link
Contributor

ro0NL commented Jul 20, 2018

TIL :)

@sir-kain perhaps #27684 might help in the future, it would tell you what %env(resolve:DATABASE_URL)% resolves to (its real value).

@sir-kain
Copy link
Contributor Author

However, I think there is a problem.
The command is only executed by the developer to have the info of his environment

@javiereguiluz
Copy link
Member

I'm closing this because, as explained, this is the expected behavior in this case. However, as @ro0NL said, we improved this a bit thanks to #27684, which shows the real value of env vars, so you can see the host and credentials when using a DATABASE_URL env var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants