8000 Unable to set a dbal connection password that starts with '@' using MySQL PDO · Issue #7402 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Unable to set a dbal connection password that starts with '@' using MySQL PDO #7402

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
mboughaba opened this issue Mar 16, 2013 · 23 comments
Closed

Comments

@mboughaba
Copy link

Hello,

I was trying to set my dbal connection using doctrine with MySQL PDO. When setting the yaml config file to use password '@SomePassword01' the framework will expect an object reference rather than a string.
This causes an exception: InvalidTypeException: Invalid type for path "doctrine.dbal.connections.default.password". Expected scalar, but got object.

Can you please have a look?
If this won't be fixed can you please at least make sure than the password requirement are mentioned correctly.

Using standard installation 2.2.0
MySQL Server 5.6
PHP 5.4.12

@pborreli
Copy link
Contributor

have you tried to put your password inside double quotes

password: "@SomePassword01"

@stood
Copy link
stood commented Mar 16, 2013

plz show your config file how config database plz

@mboughaba
Copy link
Author

No, I will try so then let you know the result.

@mboughaba
Copy link
Author

Hi pborreli,
Not working even if I am using double quotes.

#parameter.yml
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: '3306'
database_name: test
database_user: root
database_password: "@SomePassword01"
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisIsASecretRandomKey
database_path: null

#config.yml

Doctrine Configuration

doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%

orm:
    auto_generate_proxy_classes: %kernel.debug%
    auto_mapping: true

@stood
Copy link
stood commented Mar 16, 2013

ok it's a parameters file but plz show your config file.

@mboughaba
Copy link
Author

Hi stood,
Can you check my comment above I have posted both the parameters and the config file (doctrine section).
Please let me know if you may need the complete file

@stood
Copy link
stood commented Mar 16, 2013

I tried test when used a password with '@' and it's ok. Plz test connection with pdo but without sf2

@mboughaba
Copy link
Author

Please note that the password must start with '@'
It is working without sf2.
Once I have changed my root password (removing the @ sign from the beginning of the it) it works.

@stood
Copy link
stood commented Mar 16, 2013

Yes and it's ok for me but test with windows platform. Plz test connect without sf2?

@mboughaba
Copy link
Author

I am also using windows (win7) with MySQL 5.6.10. I am able to connect without sf2 the problem occurs only when trying to configure doctrine dbal using from the online _configurator or by changing manually the yaml file.

@stood
Copy link
stood commented Mar 16, 2013

Have you test with an other password without '@' ?

@egeloen
Copy link
egeloen commented Mar 16, 2013

@benamlas Have you try to double quote the value in your config.yml & in your parameters.yml?

@mboughaba
Copy link
Author

@stood, any password is working as long as it doesn't start with '@'
@egeloen yes I have tried to surround it with double quotes rather than single quotes but still not working.

Seems that the framework is expecting an object reference after the '@' rather than parsing it as a simple string.

@egeloen
Copy link
egeloen commented Mar 16, 2013

@benamlas When I said you to double quote values, I don't point the fact to use double instead of single quote, I point the fact to quote the injected parameter ("%database_password%").

@mboughaba
Copy link
Author

Still the same exception (InvalidTypeException: Invalid type for path "doctrine.dbal.connections.default.password". Expected scalar, but got object.) even with config.yml and parameters.yml entry password double quoted.

@vicb
Copy link
Contributor
vicb commented Mar 16, 2013

duplicate of #7357

@vicb vicb closed this as completed Mar 16, 2013
@tPl0ch
Copy link
tPl0ch commented Mar 18, 2013

@benamlas @egeloen @stood The problem is not with the YAML parser itself, but the way symfony handles the parameter strings inside the YamlLoader (and Dumper). So escaping, doubel/single-quoting the parameter values won't help. I have fixed this (because I had a mailer password starting with '@'), but I don't know when this will be merged unfortunately. Changing the password for now might be the only fast solution at the moment.

@mboughaba
Copy link
Author

Indeed that what I was expecting ... The exception is clear enough. However, I was thinkig that it is because of the YAML parsing.
tnx for the highlight @tPl0ch

@almaltran
Copy link

I solve this writing the password in this way:

"@@database_password"

@cAstraea
Copy link
cAstraea commented Mar 3, 2017

Any update on this ? still not working for me on symfony 2.8.17

@nicolas-grekas
Copy link
Member

@cAstraea see comment just above yours: double the @

@cAstraea
Copy link
cAstraea commented Mar 3, 2017

ah yes , was making a typo in a letter thank you

@walkingCommiter
Copy link
walkingCommiter commented Jun 17, 2019

@cAstraea Give this user a medal.

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

10 participants
0