Skip to content

Refactoring of getDbInfo and getTablesFull - #20387

Draft
kamil-tekiela wants to merge 12 commits into
phpmyadmin:masterfrom
kamil-tekiela:Refactoring-of-getDbInfo-and-getTablesFull
Draft

Refactoring of getDbInfo and getTablesFull#20387
kamil-tekiela wants to merge 12 commits into
phpmyadmin:masterfrom
kamil-tekiela:Refactoring-of-getDbInfo-and-getTablesFull

Conversation

@kamil-tekiela

Copy link
Copy Markdown
Contributor

I have worked on this PR together with Claude Fable.

This PR aims to refactor and fix multiple issues concerning table listings. Some of the issues fixed:

  • Invalid SQL when fetching table groups using IS
  • Incorrectly applied LIKE clause fetching more results than desired
  • Unstable sort, DESC sort could produce incorrect results in some cases
  • Fixed redirect when position is equal to the number of tables
  • Restrict negative position values
  • Input validation for table type param
  • Table group and table group elements are now considered equal, instead of pinning the table group to the top. I believe the pinning was an accidental feature.
  • Removed some old dead code

Claude has added some unit tests which I believe were missing before. I've built my work on top of the refactoring that Claude offered.

kamil-tekiela and others added 4 commits July 20, 2026 15:07
Add unit tests for the previously untested paths of getDbInfo(): sort
name mapping (including descending order and unknown sort columns),
the tbl_group and tbl_type filters, and MaxTableList paging.

Refactor getDbInfo() into three flat branches, replacing the
string|false $groupWithSeparator juggling and the duplicated string
checks. The sort name is now mapped with a match expression. The paging
position is passed as an explicit parameter instead of being read from
a private field, and the total table count is always returned as an int
instead of int|null, so the caller no longer needs a fallback count.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Clamp negative pos parameters to 0 in getTableListPosition(); a
negative value used to be stored in the session and end up as a
negative array_slice() offset or an invalid negative SQL OFFSET.

Redirect to the last page when the position is exactly equal to the
total number of tables: such a page is empty, but the previous check
only redirected when the position was strictly greater, rendering an
empty table list for a non-empty database.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kamil-tekiela
kamil-tekiela force-pushed the Refactoring-of-getDbInfo-and-getTablesFull branch from 027f5c8 to 6ce9836 Compare July 20, 2026 14:08
kamil-tekiela and others added 8 commits July 20, 2026 15:13
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kamil-tekiela
kamil-tekiela force-pushed the Refactoring-of-getDbInfo-and-getTablesFull branch from 6ce9836 to f049395 Compare July 20, 2026 14:16
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