Repository: doctrine-extensions/DoctrineExtensions (language: php)

Issue:
TranslationWalker CAST fails for a string fieldMapping type on MariaDB
With DBAL 4.x, an issue that was fixed a long time ago (#1011, #1024) has arisen again, specifically for MariaDB.

In the original fix (#1025), no cast is done if the current platform is an instance of MySqlPlatform, which MariaDBPlatform extended.

Unfortunately:

- In DBAL 3.x: `class MariaDBPlatform extends MySQLPlatform`
- In DBAL 4.x: `class MariaDBPlatform extends AbstractMySQLPlatform`

In effect, the check doesn't work anymore for MariaDB.


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 594bf72d2..a814c1fcb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,8 @@ a release.
 ---
 
 ## [Unreleased]
+### Fixed
+- Fix regression with `doctrine/dbal` >= 4.0 that caused MariaDB to improperly attempt LONGTEXT casting in `TranslationWalker` (issue #2887)
 
 ## [3.17.1] - 2024-10-07
 ### Fixed
diff --git a/src/Translatable/Query/TreeWalker/TranslationWalker.php b/src/Translatable/Query/TreeWalker/TranslationWalker.php
index 2c5be1564..4801ad4d1 100644
--- a/src/Translatable/Query/TreeWalker/TranslationWalker.php
+++ b/src/Translatable/Query/TreeWalker/TranslationWalker.php
@@ -10,8 +10,8 @@
 namespace Gedmo\Translatable\Query\TreeWalker;
 
 use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
 use Doctrine\DBAL\Platforms\AbstractPlatform;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
 use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
 use Doctrine\DBAL\Types\Type;
 use Doctrine\ORM\Mapping\ClassMetadata;
@@ -308,9 +308,9 @@ private function prepareTranslatedComponents(): void
 
                 // Treat translation as original field type
                 $fieldMapping = $meta->getFieldMapping($field);
-                if ((($this->platform instanceof MySQLPlatform)
+                if ((($this->platform instanceof AbstractMySQLPlatform)
                     && in_array($fieldMapping['type'], ['decimal'], true))
-                    || (!($this->platform instanceof MySQLPlatform)
+                    || (!($this->platform instanceof AbstractMySQLPlatform)
                     && !in_array($fieldMapping['type'], ['datetime', 'datetimetz', 'date', 'time'], true))) {
                     $type = Type::getType($fieldMapping['type']);
 


Test patch: