Repository navigation
fix: keep foreign keys when collating key columns - #78
Merged
Merged
Conversation
ExactColumnsCollationListener replaced the entry table on postGenerateSchemaTable with setClassTable() (DBAL 4.5+); ORM 3.7-3.8 then added the table's foreign keys to the replaced object, so any foreign key starting on the entry table, and its index, was lost on MySQL / MariaDB. None exists today (latent, audit XI). The listener now runs on postGenerateSchema once every foreign key exists: on DBAL 4.5+ the table is rebuilt with its editor and swapped in with GenerateSchemaEventArgs::setSchema(); older DBAL sets the column options in place. The platform comes from the schema tool's entity manager and managers that do not map the entry are skipped. postGenerateSchemaTable() stays as a deprecated no-op. Same collations and fallback warning. The rollup tables also get their primary key through Table::addPrimaryKeyConstraint() where DBAL has it (4.3+), keeping setPrimaryKey() for older DBAL, so building them no longer raises the setPrimaryKey() deprecation (doctrine/dbal#6867).
|
@coderabbitai review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audit XI (latent, no GHSA). Proposed patch: 1.23.1.
Problem
ExactColumnsCollationListener(1.20.1) replaced the entry table onpostGenerateSchemaTable(setClassTable(), DBAL 4.5+). ORM 3.7–3.8 then adds the table's deferred foreign keys to the old table object, so any foreign key starting on the entry table (and its index) would be dropped on MySQL / MariaDB. The entry table has none today.Fix (same pattern as ContactForm 100cf3c)
postGenerateSchema, once every foreign key exists, by table name. The service tag is updated.GenerateSchemaEventArgs::setSchema(). Older DBAL: column options are set in place.postGenerateSchemaTable()stays as a deprecated no-op. TheManagerRegistryargument is now optional and unused. The collations and the PAD SPACE warning are unchanged. The listener is stateless (worker mode with kernel reset off), and no host entity manager is cleared, reset or closed.Also (Beacon request)
RollupTables::addTo()now sets the primary keys withTable::addPrimaryKeyConstraint()where DBAL has it (4.3+).setPrimaryKey()is kept as the fallback for older DBAL. The key is the same. A newRollupTablesPrimaryKeyTestasserts that no doctrine/dbal#6867 deprecation is raised.Note: on DBAL 4.5+,
addPrimaryKeyConstraint()and the other mutableTable/Schemacalls inaddTo()raise the newer doctrine/dbal#7389 / #7373 deprecations. Clearing those needsaddTo()rewritten on the editor API, which is left as a follow-up.Tests
ExactCollationTeststeps.Local results (CI commands, Docker)
MailerCaptureListener).composer test(PHP 8.4): 1009 OK (87 skipped without servers). Coverage cell (PHP 8.2, Symfony 7.4): 5600/5600 = 100%.--group database --fail-on-skipped: 18 OK on DBAL 4.6 and on DBAL 3.10.fputcsv()deprecations and the phpunit.xml schema notice are pre-existing.🤖 Generated with Claude Code