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

Fix creating wrapped connection twice #1087

Merged
merged 1 commit into from
Dec 17, 2019
Merged

Conversation

nicolas-grekas
Copy link
Member

As explained in #1070 (comment)

Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this doesn't fully solve original problem. Also I would say tests are required here.

$params['charset'] = 'utf8';
$driver = $connection->getDriver();
$wrapperClass = Connection::class;
if (isset($params['wrapperClass'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of inlining this logic here, that's what's DriverManager for. Other places using it are still having old behaviour and in case we update DriverManager, it can break ConnectionFactory, since it unsets wrapperClass option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this should be ported to DriverManager, but fixing this here was the faster choice for Symfony users. Once this is fixed in DBAL 2.9, we can remove it here and bump the doctrine/dbal dependency.

@nicolas-grekas
Copy link
Member Author

Test added.

About your other comments @ostrolucky I didn't understand what you're suggesting instead. To me, this effectively solves the reported issue. And I can't think of any alternative implementation. Do you?

@ostrolucky
Copy link
Member

My point was it should be fixed in DriverManager::getConnection, hence in DBAL. I agree with @greg0ire. #1070 should not have been merged, I would prefer that reverted. DoctrineBundle is a glue and shouldn't act as workaround for issues in DBAL. Problems should not be removed for Symfony users only.

Besides this being ugly fix (34, poorly tested LOC with half code copy pasted; which could be < 10 in DBAL), it still instantiates original Connection class twice so by avoiding fixing it in DBAL we are implementing subpar solutions.

I believe #1070 causes other unreported issues as well. Since we are no longer touching recipe which is generated only at beginning of installing bundle, it changes charset for everybody not specifying one from usually default latin1 for MySQL < 8 into utf8mb4 which might corrupt new data.

Perhaps we can also just ignore this problem for a little while longer, since MySQL 8 fixed this itself by defaulting to utf8mb4 and nobody should start new project with MySQL 5/

Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case is incorrect. It tests that driver was instantiated once, while it should test connection wrapper is instantiated once only. Driver was never a problem.

@nicolas-grekas
Copy link
Member Author

It tests that driver was instantiated once, while it should test connection wrapper is instantiated once only.

Indeed, fixed.

@alcaeus alcaeus merged commit e13397b into doctrine:2.0.x Dec 17, 2019
@alcaeus
Copy link
Member

alcaeus commented Dec 17, 2019

Thanks @nicolas-grekas!

@nicolas-grekas nicolas-grekas deleted the fix branch July 28, 2022 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants