Fix MySQL/MariaDB platform detection for DBAL 4 compatibility#380
Conversation
|
Thanks for the PR. PHPStan reports an error about I’m not sure that DBAL 2.x or 3.2.x could be installed other dependencies may require newer versions. What issue did you encounter? Could you please share your |
ba8ebaf to
b6af382
Compare
|
Hi @alexisLefebvre I have updated my commit with what I think is a better solution.
When using MariaDB with DBAL 4, isMysql() returned false, so foreign key checks were not disabled before truncating, which caused constraint violations during fixture purging. I can't share the composer.json but I could create a small reproducer on the weekend if that would help. |
b6af382 to
72330ff
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the MySQL/MariaDB platform detection logic in ORMDatabaseTool to ensure compatibility with Doctrine DBAL 4, where MariaDBPlatform no longer extends MySQLPlatform but extends AbstractMySQLPlatform directly.
Changes:
- Replaced
instanceof MySQLPlatformcheck with string comparison usinggetPlatformName()method - Removed unused
MySQLPlatformimport
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks! Here is a release with this fix: https://github.com/liip/LiipTestFixturesBundle/releases/tag/3.8.1 |
Summary
This PR updates the MySQL platform detection logic in
ORMDatabaseToolto ensure compatibility with Doctrine DBAL 4.The Issue
In Doctrine DBAL 4,
MariaDBPlatformno longer extendsMySQLPlatformbut extendsAbstractMySQLPlatformdirectly. This caused theinstanceof MySQLPlatformcheck inisMysql()to returnfalseon MariaDB setups, preventing the bundle from correctly disabling/enabling foreign key checks when purging the database with truncate.The Fix
I've updated
isMysql()to use the already existinggetPlatformName()method fromAbstractDbalDatabaseTool.This method already has the check for the newer
AbstractMySQLPlatformwhich is the highest common ancestor of bothMySQLPlatformandMariaDBPlatform.This ensures that the platform check
isMysql()insidedisableForeignKeyChecksIfApplicableandenableForeignKeyChecksIfApplicablereturns true and foreign key checks are disabled/enabled correctly when called using a MariaDB database with DBAL 4.Testing