Skip to content

Fix wrong parent id and missing table guard in migrations - #85

Open
ericges wants to merge 5 commits into
contao-bootstrap:masterfrom
ericges:fix/migration-element-group-id
Open

Fix wrong parent id and missing table guard in migrations#85
ericges wants to merge 5 commits into
contao-bootstrap:masterfrom
ericges:fix/migration-element-group-id

Conversation

@ericges

@ericges ericges commented Aug 31, 2026

Copy link
Copy Markdown
Contributor
  1. GridWrapperMigration::insertElementGroup() returned the value of Connection::insert(), which is the affected row count and therefore always 1, not the id of the new record. That value was passed straight into moveElementsToParent() as the new pid, so content elements in multi-element grid slots were reparented onto whatever record happens to be tl_content.id = 1. Read the id with lastInsertId() instead, which runs on the same connection and inside the same transaction as the insert.
  2. SizeIndexMigration::getSizes() called listTableColumns('tl_theme') without checking that the table exists, throwing instead of skipping. Guard it with tablesExist() and return no sizes, consistent with the adjacent missing-column early return.
  3. array_merge() in a loop is a resource greedy construction. Changed one instance to array_push() as a minor improvement.

GridWrapperMigration::insertElementGroup() returned the value of
Connection::insert(), which is the affected row count and therefore always
1, not the id of the new record. That value was passed straight into
moveElementsToParent() as the new pid, so content elements in multi-element
grid slots were reparented onto whatever record happens to be
tl_content.id = 1 - silent data corruption rather than an error. Read the
id with lastInsertId() instead, which runs on the same connection and
inside the same transaction as the insert.

SizeIndexMigration::getSizes() called listTableColumns('tl_theme') without
checking that the table exists, throwing instead of skipping on an
installation without Contao tables. Guard it with tablesExist() and return
no sizes, consistent with the adjacent missing-column early return.
- Ensure `$sizes` is correctly typecast as an array.
- Replace incorrect `array_push` assignment with valid usage.
- Remove redundant assignment of `array_push` result to `$sizes`.
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.

1 participant