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

PDO DSN generation failes when initStatement contains ; #6526

Closed
tomvlk opened this issue Sep 7, 2016 · 6 comments
Closed

PDO DSN generation failes when initStatement contains ; #6526

tomvlk opened this issue Sep 7, 2016 · 6 comments
Labels
bug report Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release triage wanted

Comments

@tomvlk
Copy link

tomvlk commented Sep 7, 2016

Preconditions

  1. Install Magento2 with setup (MySQL), don't change default initStatement.

Steps to reproduce

  1. Edit the app/etc/env.php.
  2. Change the order of the default db connection configuration.
  3. Make sure that initStatement is the upper most entry.
  4. Reload page or run CLI tool.

Expected result

  1. Working site with selected DB.

Actual result

  1. The DSN will contain the initStatement with ; sign. Resulting in:
mysql:host=localhost;model=mysql4;active=1;initStatements=SET NAMES utf8;;dbname=test_db;engine=innodb;type=pdo_mysql

The problem will be between the initStatements= and the dbname=. The dubble semicolon will result in ignoring everything after it.

By default the Magento setup will add initStatements with the semicolon on the end, which is the failt. The only reason why it isn't failing on all environments is order of the env.php array which will ignore nothing on the end of the generated DSN.

This affects Magento 2.1.1 and (not yet tested) everything < 2.1.1.

@sevos1984
Copy link
Contributor

Why do you need to change order of configurations?

@tomvlk
Copy link
Author

tomvlk commented Sep 9, 2016

@sevos1984 Because there are deployment tools out there that use un-ordered lists (language limitations) and will output it in a random order. For such environments, it's possible to implement a workaround at the deployment side. But this is definitely a bug with the default value of the initStatements.

It's good configured in your tests (

['host' => 'localhost', 'initStatements' => 'SET NAMES utf8', 'type' => 'pdo_mysql', 'active' => false],
) but in the default setup config it's including the semicolon which can, together with a different order, result in a exception.

@sevos1984
Copy link
Contributor

Thanks for clarification, internal ticket created MAGETWO-58326

@sevos1984 sevos1984 added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 13, 2016
@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@tomvlk, thank you for your report.
We've created internal ticket(s) MAGETWO-58326 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Oct 18, 2017
@magento-engcom-team
Copy link
Contributor

@tomvlk, thank you for your report.

Unfortunately, we are archiving this ticket now as it did not get much attention from both Magento Community and Core developers for an extended period. This is done in an effort to create a quality, community-driven backlog which will allow us to allocate the required attention more easily.

You may learn more about this initiative following this link.

Please feel free to comment or reopen the ticket if you think it should be reviewed once more. Thank you for collaboration.

@Hailong
Copy link
Member

Hailong commented Aug 28, 2019

I'd suggested a PR to fix this issue, since it's kind of a common issue. magento/zf1#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release triage wanted
Projects
None yet
Development

No branches or pull requests

5 participants