Skip to content

Fix #20190 - Handle missing parser statement in getForeigners()#20316

Open
eyupcanakman wants to merge 1 commit into
phpmyadmin:QA_5_2from
eyupcanakman:fix/getforeigners-empty-statements-20190
Open

Fix #20190 - Handle missing parser statement in getForeigners()#20316
eyupcanakman wants to merge 1 commit into
phpmyadmin:QA_5_2from
eyupcanakman:fix/getforeigners-empty-statements-20190

Conversation

@eyupcanakman
Copy link
Copy Markdown
Contributor

Description

getForeigners() reads $parser->statements[0] after parsing the SHOW CREATE TABLE output, but the parser returns no statement for some tables, for example a binary column with a binary default value. That raises Undefined array key 0. The instanceof CreateStatement check right after already handles null.

Same pattern on master in getForeignKeysData().

Fixes #20190.

…rs()

getForeigners() reads the first parsed statement of the SHOW CREATE TABLE output.
Some tables leave the parser with an empty statements array, for example a binary(16) column with a binary DEFAULT value, so reading statements[0] raises "Undefined array key 0".
Guard the access with "?? null", which the existing instanceof CreateStatement check already treats as no foreign keys.

Signed-off-by: Eyüp Can Akman <eyupcanakman@gmail.com>
@eyupcanakman eyupcanakman force-pushed the fix/getforeigners-empty-statements-20190 branch from c983176 to 308a715 Compare May 24, 2026 20:43
Copy link
Copy Markdown
Member

@williamdes williamdes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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.

2 participants