Repository navigation
Conversation
ibexa_search_object_word_link gets language_id and is_main_and_always_available columns, filled from its mask. The field criteria and sort clause, the full-text and language code criteria and the language filter of content and location search use the join tables and those columns instead of arithmetic on the masks. The indexer keeps writing the word link mask until the bitmask is removed, and field language ids are compared without their always-available bit until it is stripped.
…ws instead of loading content translations
…pes in the legacy search classes
…spectTableByUnquotedName()
ReindexCommand passes the --content-ids values as strings, and the untyped remove() hands them on to SearchIndex's int parameters, which strict types turned into a TypeError for deleted or unpublished content.
… for the returned page only
ibexa_url_alias_ml gets an is_always_available column, and an alias's languages come from ibexa_url_alias_ml_translation instead of lang_mask, in cleandata.sql too. The gateway keeps lang_mask in step with them until the bitmask is removed.
… share with the new content
…_available Same flag as always_available on ibexa_content and ibexa_content_version.
…pes in the URL alias handler and mapper
…spectTableByUnquotedName()
…tries get relinked to
…the URL alias and search index migrations
Content types read their languages from ibexa_content_type_name instead of decoding the type's language_mask, and resolve language ids through the language handler instead of MaskGenerator. They keep writing the mask and the always-available bit of their name rows until the bitmask is removed.
…pes in the content type mapper
Object states resolve language ids through the language handler instead of MaskGenerator. They keep writing the masks and the always-available bit until the bitmask is removed.
Stops writing the masks and drops them, together with MaskGenerator. New languages get the id after the highest one instead of the next power of two, which lifts the limit of 62 languages, and the always-available bit is stripped from the language_id columns, after removing the stale object state translations eZ Publish left behind.
…disagrees with them
…ge instead of the shape of the ids
…ead of refusing the delete
…en't a language, and from core's test data itself
…ed in languages beyond the old limit
… mapper and search index repository
…spectTableByUnquotedName()
… a seeded pre-6.0 database
…bitmask upgrade test IBX-13070 removed SchemaAssetsFilterBypass, and LegacySchemaImporter no longer takes one.
The names and fields of a version only matched its languages with the always-available bit added too, which the language ids don't carry anymore.
…guage table The initial language of content, versions and content types, the language of fields, content names, content type names and object state translations, and the default language of object states and groups now reference ibexa_content_language, ON DELETE RESTRICT ON UPDATE CASCADE like the translation tables. The field definition translations' foreign key, ON DELETE CASCADE until now, follows suit under a new name. AddLanguageForeignKeysMigration adds them after the bitmask migrations, refusing while any row holds a language id without a language. SQLite rebuilds the tables. schema.yaml lists the language table first and the clean data inserts it first; FixtureImporter inserts it first and detaches every row referencing it when a fixture replaces the languages; fixtures and tests use language ids that exist.
…gn key MySQL and MariaDB can't roll back schema changes, so a failure halfway through the single migration left some of the foreign keys added and others not. Each foreign key now has its own migration, which adds it together with its index in one statement and skips itself when the key is already there, so the migrations' status shows which ones are in.
…he language table
…nition translations when it's missing
… id before deleting a language
…nguage foreign keys test
…ort test with TestWith attributes
…adding their foreign key
…key rebuilds The migrations run outside a transaction on SQLite, so PRAGMA foreign_keys can be switched off around the table rebuild, and back on afterwards, instead of aborting when the connection enforces foreign keys.
Steveb-p
force-pushed
the
IBX-13235-object-state-foreign-keys
branch
from
November 19, 2026 13:28
497009a to
9a656a1
Compare
|
Steveb-p
force-pushed
the
feature/language-foreign-keys-6.0
branch
from
November 21, 2026 16:16
9997c72 to
b6a64be
Compare
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.



Note
Stacked on #964: on SQLite these migrations rebuild the same tables #964 rebuilds for its language keys, and keep them. I'll retarget it to
6.0once #964 lands.Related PRs:
Description:
The object state tables referenced each other only by convention, so nothing stopped a deleted state or group from leaving its translations or content assignments behind. They now have foreign keys, all
ON UPDATE CASCADE:ibexa_object_state.group_id→ibexa_object_state_group.id,ON DELETE RESTRICTibexa_object_state_group_language.contentobject_state_group_id→ibexa_object_state_group.id,ON DELETE CASCADEibexa_object_state_language.contentobject_state_id→ibexa_object_state.id,ON DELETE CASCADEibexa_object_state_link.contentobject_state_id→ibexa_object_state.id,ON DELETE RESTRICTibexa_object_state_link.contentobject_id→ibexa_content.id,ON DELETE CASCADETranslations cascade like the other translation tables (
ibexa_content_translationetc.), and the gateway deletes them before the state or group anyway. A state still assigned to content, or a group still holding states, is RESTRICT: the content has to be moved to another state first, which is whatObjectState\Handleris for. ExceptHandler::delete()deleted the state before moving its content to the group's default state, so with RESTRICT it'd fail, and with CASCADE the content would silently lose its state in that group. It now moves the links first (or deletes them, for the last state of a group) and deletes the state after.deleteGroup()already deleted the links, then the states, then the group.Deleting content never removed its state links (
TreeHandler::removeRawContent()doesn't touch them), so pretty much every site has links of deleted content, andObjectStateService::getContentCount()counts them. That key cascades, and its migration deletes those links before adding it instead of aborting, as they point at nothing.Each key has its own migration on top of
AbstractAddObjectStateForeignKeyMigration, like #964's language keys: it skips itself when the key is already there, refuses with a row count when a column points at a state or group that doesn't exist, and on SQLite rebuilds the table outside a transaction, withPRAGMA foreign_keysswitched off for the rebuild, as #964's do. Onlyibexa_object_state_link.contentobject_state_idneeded a new index (ibexa_object_state_link_state), the other columns lead an existing primary or unique key.For tests and the legacy install path,
schema.yamlnow listsibexa_object_state_groupbeforeibexa_object_stateandibexa_object_state_linkafteribexa_content(the test schema is dropped in reverse), and the clean data inserts them in that order.FixtureImporternow orders a fixture's tables by their foreign keys rather than only putting the language table first, astest_data.yamllists the states before their group and the links before the content. When a fixture replaces the languages, it also sets the state links aside, puts the set-aside rows back in the same foreign key order as the fixture's own (so the links ofobjectstates.phpdon't go in before the content they point at), and skips those whose state, group or content is gone.For QA:
By hand: on a 5.0 database with some content deleted (trash emptied), run
ibexa:doctrine:migrations:migrate. It reports how many state links of deleted content it removed. Then delete an object state assigned to some content and check the content moved to the group's default state.Documentation:
For the 6.0 upgrade guide:
AddObjectStateLinkContentForeignKeyMigrationdeletes the object state assignments of content that doesn't exist anymore. The otherAddObjectState*ForeignKeyMigrationmigrations stop the upgrade when a state, translation or assignment points at a state or group that doesn't exist anymore, naming the column; those rows have to be deleted before migrating again.