Skip to content

Fix MySQL/MariaDB platform detection for DBAL 4 compatibility#380

Merged
alexisLefebvre merged 1 commit into
liip:3.xfrom
henryfoster:fix-dbal4-mysql-mariadb-detection
Feb 20, 2026
Merged

Fix MySQL/MariaDB platform detection for DBAL 4 compatibility#380
alexisLefebvre merged 1 commit into
liip:3.xfrom
henryfoster:fix-dbal4-mysql-mariadb-detection

Conversation

@henryfoster

@henryfoster henryfoster commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR updates the MySQL platform detection logic in ORMDatabaseTool to ensure compatibility with Doctrine DBAL 4.

The Issue

In Doctrine DBAL 4, MariaDBPlatform no longer extends MySQLPlatform but extends AbstractMySQLPlatform directly. This caused the instanceof MySQLPlatform check in isMysql() to return false on 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 existing getPlatformName() method from AbstractDbalDatabaseTool.
This method already has the check for the newer AbstractMySQLPlatform which is the highest common ancestor of both MySQLPlatform and MariaDBPlatform.

This ensures that the platform check isMysql() inside disableForeignKeyChecksIfApplicable and enableForeignKeyChecksIfApplicable returns true and foreign key checks are disabled/enabled correctly when called using a MariaDB database with DBAL 4.

Testing

  • All tests passed.

@alexisLefebvre

alexisLefebvre commented Feb 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR.

PHPStan reports an error about AbstractPlatform that is not used here, that is strange.

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 composer.json?

@henryfoster
henryfoster force-pushed the fix-dbal4-mysql-mariadb-detection branch from ba8ebaf to b6af382 Compare February 17, 2026 19:12
@henryfoster henryfoster changed the title Fix MySQL/MariaDB platform detection for DBAL 4 compatibility Fix MySQL/MariaDB platform detection for DBAL 3.3 compatibility Feb 17, 2026
@henryfoster

henryfoster commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

Hi @alexisLefebvre I have updated my commit with what I think is a better solution.
I also updated the description and hope the issue is now clearer. Let me know if it is not.

What issue did you encounter?

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.

@henryfoster henryfoster changed the title Fix MySQL/MariaDB platform detection for DBAL 3.3 compatibility Fix MySQL/MariaDB platform detection for DBAL 4 compatibility Feb 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 MySQLPlatform check with string comparison using getPlatformName() method
  • Removed unused MySQLPlatform import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alexisLefebvre
alexisLefebvre merged commit c05c8ff into liip:3.x Feb 20, 2026
17 checks passed
@alexisLefebvre

Copy link
Copy Markdown
Collaborator

Thanks!

Here is a release with this fix: https://github.com/liip/LiipTestFixturesBundle/releases/tag/3.8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants