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 getWrappedConnection is deprecated #222

Merged
merged 2 commits into from
Oct 8, 2024
Merged
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
17 changes: 10 additions & 7 deletions src/Provider/Doctrine/Persistence/Helper/PlatformHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@
}

$platform = $connection->getDatabasePlatform();
$version = self::getServerVersion($connection);

if (null === $version) {
return false;
}

// JSON wasn't supported on MariaDB before 10.2.7
// @see https://mariadb.com/kb/en/json-data-type/
if ($platform instanceof MariaDBPlatform) {
if ($platform instanceof MariaDBPlatform && ($version = self::getServerVersion($connection))) {
return version_compare(self::getMariaDbMysqlVersionNumber($version), '10.2.2', '<');
}

if ($platform instanceof MySQLPlatform) {
if ($platform instanceof MySQLPlatform && ($version = self::getServerVersion($connection))) {
return version_compare(self::getOracleMysqlVersionNumber($version), '5.7.7', '<');
}

Expand All @@ -49,6 +44,14 @@

public static function getServerVersion(Connection $connection): ?string
{
if (method_exists($connection, 'getNativeConnection') && ($pdo = $connection->getNativeConnection()) instanceof \PDO) {
$version = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
if (\is_string($version)) {
return $version;
}

return null;

Check warning on line 53 in src/Provider/Doctrine/Persistence/Helper/PlatformHelper.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/Doctrine/Persistence/Helper/PlatformHelper.php#L53

Added line #L53 was not covered by tests
}
$reflected = new \ReflectionObject($connection);
if ($reflected->hasMethod('getServerVersion') && $reflected->getMethod('getServerVersion')->isPublic()) {
return $connection->getServerVersion();
Expand Down