Skip to content

Fix SQL history not stored or shown in the console - #20558

Open
xmaks82 wants to merge 2 commits into
phpmyadmin:masterfrom
xmaks82:console-history-lazy-relation
Open

xmaks82 wants to merge 2 commits into
phpmyadmin:masterfrom
xmaks82:console-history-lazy-relation

Conversation

@xmaks82

@xmaks82 xmaks82 commented Oct 23, 2026

Copy link
Copy Markdown

Description

With the configuration storage and $cfg['QueryHistoryDB'] = true, the console history tab stays empty and nothing is written to pma__history.

Console\History reads sqlHistoryFeature in its constructor. The service is built early, before authentication (the ResponseRenderer needs Header -> Console -> History, e.g. in TokenRequestParamChecking), when the relation parameters are still empty. Authentication later calls initRelationParamsCache(), but History keeps the empty value for the whole request.

To reproduce: configure pmadb with the history table, enable QueryHistoryDB, run a few queries and open the console History tab, or check pma__history.

The feature is now read from Relation when it is used. Added tests/unit/Console/HistoryTest.php, which fails without the change.

  • Make sure you have read our CONTRIBUTING.md document.
  • Make sure you are making a pull request against the correct branch. For example, for bug fixes in a released version use the corresponding QA branch and for new features use the master branch. If you have a doubt, you can ask as a comment in the bug report or on the mailing list.
  • Every commit has proper Signed-off-by line as described in our DCO. This ensures that the work you're submitting is your own creation.
  • Every commit has a descriptive commit message.
  • Every commit is needed on its own, if you have just minor fixes to previous commits, you can squash them.
  • Any new functionality is covered by tests.

History read the SQL history feature in its constructor. The service is
created before the user is authenticated (the response renderer needs the
console), so it kept the empty relation parameters and the history was
never saved to nor read from the configuration storage.

Read the relation parameters when they are needed instead.

Signed-off-by: Магда М.Г. <mail@mgmagda.ru>
Comment thread src/Console/History.php Outdated
private function getSqlHistoryFeature(): SqlHistoryFeature|null
{
$this->sqlHistoryFeature = $relation->getRelationParameters()->sqlHistoryFeature;
return $this->relation->getRelationParameters()->sqlHistoryFeature;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You don't need a method for one line and you definitely don't need that comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done: removed the method and the comment, the lookup is inline now.

Signed-off-by: Магда М.Г. <mail@mgmagda.ru>
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