Fix wrong parent id and missing table guard in migrations - #85
Open
ericges wants to merge 5 commits into
Open
Conversation
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`.
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.
GridWrapperMigration::insertElementGroup()returned the value ofConnection::insert(), which is the affected row count and therefore always1, not the id of the new record. That value was passed straight intomoveElementsToParent()as the newpid, so content elements in multi-element grid slots were reparented onto whatever record happens to betl_content.id = 1. Read the id withlastInsertId()instead, which runs on the same connection and inside the same transaction as the insert.SizeIndexMigration::getSizes()calledlistTableColumns('tl_theme')without checking that the table exists, throwing instead of skipping. Guard it withtablesExist()and return no sizes, consistent with the adjacent missing-column early return.array_merge()in a loop is a resource greedy construction. Changed one instance toarray_push()as a minor improvement.