IBX-12603: Resolved Ibexa DB platform when generating test database schema - #52
Conversation
DatabaseSchemaHook generated DDL with $connection->getDatabasePlatform(), which returns vanilla Doctrine SQLitePlatform. That platform drops the table-level PRIMARY KEY clause whenever a table has an autoincrement column, so composite keys degraded to a single column and fixture import failed on ibexa_content_field(id, version). DBAL 4 removed doctrine-bundle's platform_service, so the connection no longer carries Ibexa's platform subclasses. Resolve them explicitly via DbPlatformFactoryInterface, the same way CoreInstaller and LegacySchemaImporter already do. Affects 6.0 only. 4.6 and 5.0 are on DBAL 3 and still wire platform_service. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
6.0 integration test bootstrap fails on SQLite because DatabaseSchemaHook generates DDL with the vanilla Doctrine platform, losing composite primary keys. The fix lives in ibexa/test-core, nothing in this repository changes. dependencies.json makes CI install that branch, so the fix can be proven here before it merges. Generated with ci dependencies:link, must be dropped once ibexa/test-core#52 is merged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Builds a schema with a composite primary key over an autoincrement column, the shape ibexa_content_field has, and asserts the emitted DDL keeps PRIMARY KEY (id, version). Fails against the previous code, which took the platform off the connection. This is the guard for the SchemaApplier work on 4.6: if that call site goes back to $connection->getDatabasePlatform() when the chain merges up, this test fails instead of the bug returning silently. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
php_unit_test_case_static_method_calls rewrites $this->createStub() to self::, which contradicts PHPStorm's EA inspection. createStub is a non-static method in PHPUnit 9, so $this-> is the accurate form here. The fixer matches on method name across PHPUnit versions and assumes PHPUnit 10+, where createStub did become static, hence the disagreement. Overriding the call type for that one method keeps the rest of the suite on self::. Revisit when moving to PHPUnit 10+, where the override stops being correct. Bumped ibexa/code-style to ~2.3.0 while at it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| 'inline_constructor_arguments' => false, | ||
| ], | ||
| 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], | ||
| 'php_unit_test_case_static_method_calls' => ['call_type' => 'self', 'methods' => ['createStub' => 'this']], |
There was a problem hiding this comment.
Note
Well... That fixer is of... questionable quality. It hard-codes list of method it thinks should be static rather than inferring from the installed source (maybe can't?). PHPUnit methods' signatures change across different PHPUnit version. Right now createStub is not static (PHPUnit 9).
There was a problem hiding this comment.
maybe that should be delegated to phpstan? tbh, fixer saying that something is static or not seems kinda too much.
There was a problem hiding this comment.
maybe that should be delegated to phpstan? tbh, fixer saying that something is static or not seems kinda too much.
Yeah, not sure why it was enabled here. It belongs to the @PhpCsFixer:risky rule set, not enabled by default.
I can drop it completely.
POV ping @Steveb-p
| "require-dev": { | ||
| "phpunit/phpunit": "^9", | ||
| "ibexa/code-style": "^2.0", | ||
| "ibexa/code-style": "~2.3.0", |
There was a problem hiding this comment.
Bumped while at it, causes no CS drifts.
| 'inline_constructor_arguments' => false, | ||
| ], | ||
| 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], | ||
| 'php_unit_test_case_static_method_calls' => ['call_type' => 'self', 'methods' => ['createStub' => 'this']], |
There was a problem hiding this comment.
maybe that should be delegated to phpstan? tbh, fixer saying that something is static or not seems kinda too much.
Steveb-p
left a comment
There was a problem hiding this comment.
Good enough to unblock.
Related PRs:
Description:
DatabaseSchemaHookgenerates DDL with$connection->getDatabasePlatform(), which since the DBAL 4 upgrade returns vanillaDoctrine\DBAL\Platforms\SQLitePlatforminstead of ourSqliteDbPlatform. Vanilla SQLitePlatform drops the table-levelPRIMARY KEY (...)clause as soon as a table has an autoincrement column, so composite keys silently degrade to a single column:ibexa_content_fieldis keyed on(id, version), one row per content version, so the fixture repeatsidon purpose and the import dies in bootstrap withUNIQUE constraint failed: ibexa_content_field.id.ibexa_content_typeandibexa_content_type_field_definitionlose their(id, status)key the same way. This is what makesibexa/core6.0red: run 34885080403.SQLite only,
6.0only. It took two changes to get here:platform_service, gone in DBAL 4. It compensated inCoreInstallerandLegacySchemaImporter, but this hook was missed.4.6and5.0are on DBAL 3 and still wireplatform_service, so the connection returns the right platform there.SchemaBuilderInterface. Before that it delegated toLegacySchemaImporter, which resolves the platform viaDbPlatformFactory.DbPlatformFactoryInterfaceinstead of taking it off the connection, the same wayCoreInstallerandLegacySchemaImporteralready doDatabaseSchemaHookTest- builds a schema shaped likeibexa_content_fieldand asserts the emitted DDL keepsPRIMARY KEY (id, version). Confirmed it fails against the previous code.php_unit_test_case_static_method_callsforcreateStubonly - it is not static in PHPUnit 9, so$this->is the accurate form and PHPStorm flagsself::. Bumpedibexa/code-styleto~2.3.0while at it.composer integrationonibexa/core6.0with this branch symlinked in: legacy suite 11417 tests green,phpunit-integration.xml79 tests green (was dying in bootstrap)composer check-cs,composer test,composer phpstangreen hereThe test is deliberately a tripwire for the note below rather than broad coverage - it fails if this call site ever goes back to the connection's platform. Real integration coverage of
SqliteDbPlatformDDL generation belongs inibexa/doctrine-schema, not here.Note
ibexa/doctrine-schema#49 moves this call site onto a new
SchemaApplier, which carries the same$connection->getDatabasePlatform(), plusConnection::getSchemaManager()andgetDropTableSQL(Table)- both gone in DBAL 4. That chain is based on4.6, so all three need handling when it merges up into6.0, otherwise this comes back.For QA:
No QA required. CI covers it:
Documentation:
No documentation required.
🤖 Generated with Claude Code