From 20ca1a18234a198da11d534e3bc0c83295b512d1 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 5 Nov 2023 23:33:45 +0100 Subject: [PATCH] Extend AbstractMySQLPlatform::getColumnTypeSQLSnippets() deprecation layer --- UPGRADE.md | 8 +++++--- psalm.xml.dist | 1 + src/Platforms/AbstractMySQLPlatform.php | 8 ++++++++ src/Platforms/MariaDb1043Platform.php | 11 +++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 43d648159be..06e70fdcd3c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,10 +8,12 @@ awareness about deprecated code. # Upgrade to 3.8 -## Deprecated `AbstractMySQLPlatform::getColumnTypeSQLSnippets()` +## Deprecated `AbstractMySQLPlatform` methods -`AbstractMySQLPlatform::getColumnTypeSQLSnippets()` has been deprecated. -Use `AbstractMySQLPlatform::getColumnTypeSQLSnippet()` instead. +* `AbstractMySQLPlatform::getColumnTypeSQLSnippets()` has been deprecated + in favor of `AbstractMySQLPlatform::getColumnTypeSQLSnippet()`. +* `AbstractMySQLPlatform::getDatabaseNameSQL()` has been deprecated without replacement. +* Not passing a database name to `AbstractMySQLPlatform::getColumnTypeSQLSnippet()` has been deprecated. ## Deprecated reset methods from `QueryBuilder` diff --git a/psalm.xml.dist b/psalm.xml.dist index eb12a6885fc..0eb1e5ced86 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -511,6 +511,7 @@ TODO: remove in 4.0.0 --> + diff --git a/src/Platforms/AbstractMySQLPlatform.php b/src/Platforms/AbstractMySQLPlatform.php index 485d4d8bb8e..bc409bdf4cb 100644 --- a/src/Platforms/AbstractMySQLPlatform.php +++ b/src/Platforms/AbstractMySQLPlatform.php @@ -1422,8 +1422,16 @@ public function supportsColumnLengthIndexes(): bool return true; } + /** @deprecated Will be removed without replacement. */ protected function getDatabaseNameSQL(?string $databaseName): string { + Deprecation::triggerIfCalledFromOutside( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/6215', + '%s is deprecated without replacement.', + __METHOD__, + ); + if ($databaseName !== null) { return $this->quoteStringLiteral($databaseName); } diff --git a/src/Platforms/MariaDb1043Platform.php b/src/Platforms/MariaDb1043Platform.php index 8ba6792ed01..5f51ac34cc9 100644 --- a/src/Platforms/MariaDb1043Platform.php +++ b/src/Platforms/MariaDb1043Platform.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Types\JsonType; +use Doctrine\Deprecations\Deprecation; use function sprintf; @@ -81,6 +82,16 @@ public function getColumnTypeSQLSnippet(string $tableAlias = 'c', ?string $datab return parent::getColumnTypeSQLSnippet($tableAlias, $databaseName); } + if ($databaseName === null) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/6215', + 'Not passing a database name to methods "getColumnTypeSQLSnippet()", ' + . '"getColumnTypeSQLSnippets()", and "getListTableColumnsSQL()" of "%s" is deprecated.', + self::class, + ); + } + $databaseName = $this->getDatabaseNameSQL($databaseName); // The check for `CONSTRAINT_SCHEMA = $databaseName` is mandatory here to prevent performance issues