5.next: Fix TypeError: TableSchema::getConstraint#19090
Merged
Conversation
markstory
approved these changes
Nov 26, 2025
Member
Author
|
@markstory I thought this was part of 5.next as I had those in my test suite here. but turns out also other projects running on 5.x (latest tag) have the same issue.
I think we need to backport this to current 5.x |
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.
Follow #19089
Annoying PHP behavior that keys of int even set as string revert to int.
So we have two options: A costly one (correct approach) to string cast on the returns:
public function columns(): array { - return array_keys($this->_columns); + // Cast to string to handle numeric column names (PHP converts "1" to int 1 as array key) + return array_map('strval', array_keys($this->_columns)); } /** @@ -602,7 +603,8 @@ class TableSchema implements TableSchemaInterface, SqlGeneratorInterface */ public function indexes(): array { - return array_keys($this->_indexes); + // Cast to string to handle numeric index names (PHP converts "1" to int 1 as array key) + return array_map('strval', array_keys($this->_indexes)); } /** @@ -829,7 +831,8 @@ class TableSchema implements TableSchemaInterface, SqlGeneratorInterface */ public function constraints(): array { - return array_keys($this->_constraints); + // Cast to string to handle numeric constraint names (PHP converts "1" to int 1 as array key) + return array_map('strval', array_keys($this->_constraints)); }or the simple approach in this PR.