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 deprecations for deprecated mysql server versions #1781

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ public function createConnection(array $params, ?Configuration $config = null, ?
$driver = $connection->getDriver();
/** @psalm-suppress InvalidScalarArgument Bogus error, StaticServerVersionProvider implements Doctrine\DBAL\ServerVersionProvider */
$platform = $driver->getDatabasePlatform(
...(class_exists(StaticServerVersionProvider::class) ? [new StaticServerVersionProvider($params['serverVersion'] ?? '')] : []),
...(class_exists(StaticServerVersionProvider::class)
? [new StaticServerVersionProvider($params['serverVersion'] ?? $params['primary']['serverVersion'] ?? '')]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to check this one a bit more: might be a bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This indeed was a bug however not really a big issue. The only thing we need to know further below is if $platform is an instance of AbstractMySQLPlatform and thats true anyway no matter which mysql version we use.

But this fix is needed to be deprecation free and to use the proper static version then.

This is in line with https://github.com/doctrine/dbal/blob/c70bae9e69e0e543044d5e282a624d9b3cbea6fb/src/Connection.php#L185-L189

: []
),
);

if (! isset($params['charset'])) {
Expand Down
4 changes: 2 additions & 2 deletions tests/ConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testDefaultCharsetNonMySql(): void
public function testDefaultCharsetMySql(): void
{
$factory = new ConnectionFactory([]);
$params = ['driver' => 'pdo_mysql'];
$params = ['driver' => 'pdo_mysql', 'serverVersion' => '8.0.31'];

$connection = $factory->createConnection($params, $this->configuration);

Expand All @@ -53,7 +53,7 @@ public function testDefaultCharsetMySql(): void
public function testDefaultCollationMySql(): void
{
$factory = new ConnectionFactory([]);
$connection = $factory->createConnection(['driver' => 'pdo_mysql'], $this->configuration);
$connection = $factory->createConnection(['driver' => 'pdo_mysql', 'serverVersion' => '8.0.31'], $this->configuration);

$this->assertSame(
'utf8mb4_unicode_ci',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
<connection name="connection1" schema-filter="~^(?!t_)~" server-version="8.0.31" />
<connection name="connection2" server-version="8.0.31" />
<connection name="connection3" server-version="8.0.31" />
</dbal>
</config>
</srv:container>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<config>
<dbal default-connection="default">
<connection name="default" dbname="db" />
<connection name="default" dbname="db" server-version="8.0.31" />
</dbal>

<orm enable-lazy-ghost-objects="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ doctrine:
connections:
connection1:
schema_filter: ~^(?!t_)~
connection2: []
connection3: []
server_version: 8.0.31
connection2:
server_version: 8.0.31
connection3:
server_version: 8.0.31
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ doctrine:
connections:
default:
dbname: db
server_version: 8.0.31

orm:
enable_lazy_ghost_objects: true
Expand Down
Loading