From 4d0fa8722722e851078ce9d9d1a78c8a3174a413 Mon Sep 17 00:00:00 2001 From: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com> Date: Sun, 26 Apr 2026 11:39:41 +0200 Subject: [PATCH] Fix #20253 - Missing parameter: db when clicking on index in tree Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com> --- resources/templates/navigation/tree/node.twig | 6 ++- tests/unit/Navigation/NavigationTreeTest.php | 44 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/resources/templates/navigation/tree/node.twig b/resources/templates/navigation/tree/node.twig index e9f6251a53..668f09aa54 100644 --- a/resources/templates/navigation/tree/node.twig +++ b/resources/templates/navigation/tree/node.twig @@ -36,7 +36,11 @@ {% if node_is_container %}  {{ node.name }} {% elseif 'index' in node.classes %} - + {# No `disableAjax`: this link relies on `data-post` for its params, which #} + {# is consumed by the AJAX request handler (Generator::linkOrButton). With #} + {# `disableAjax` the browser navigates natively to the href, which carries #} + {# only the route, and the controller fails with "Missing parameter: db". #} + {{- displayName -}} {% else %} diff --git a/tests/unit/Navigation/NavigationTreeTest.php b/tests/unit/Navigation/NavigationTreeTest.php index 326099e0ac..8b9399aa35 100644 --- a/tests/unit/Navigation/NavigationTreeTest.php +++ b/tests/unit/Navigation/NavigationTreeTest.php @@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Current; use PhpMyAdmin\Dbal\DatabaseInterface; use PhpMyAdmin\Navigation\NavigationTree; +use PhpMyAdmin\Navigation\Nodes\NodeIndex; use PhpMyAdmin\Template; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\ResponseRenderer; @@ -96,4 +97,47 @@ class NavigationTreeTest extends AbstractTestCase self::assertStringContainsString('functions__a', $result); self::assertStringContainsString('functions__b', $result); } + + /** + * Regression test for https://github.com/phpmyadmin/phpmyadmin/issues/20253: + * The link to a specific index in the navigation tree must NOT have the + * `disableAjax` class. The link relies on `data-post` for `db`/`table`/ + * `index`, which is consumed by the AJAX request handler — with + * `disableAjax` the browser navigates natively to the bare href and the + * controller fails with "Missing parameter: db". + */ + public function testIndexNodeLinkUsesAjaxFlow(): void + { + $config = new Config(); + $template = new Template($config); + $node = new NodeIndex($this->createDatabaseInterface(), $config, 'idx_mail'); + + $output = $template->render('navigation/tree/node', [ + 'node' => $node, + 'displayName' => 'idx_mail', + 'class' => '', + 'show_node' => true, + 'has_siblings' => false, + 'li_classes' => '', + 'control_buttons' => '', + 'node_is_container' => false, + 'has_second_icon' => false, + 'recursive' => ['html' => '', 'has_wrapper' => false, 'is_hidden' => false], + 'icon_links' => [], + 'text_link' => [ + 'route' => '/table/indexes', + 'params' => ['db' => 'testdb', 'table' => 'users', 'index' => 'idx_mail'], + 'title' => 'Edit', + 'is_ajax' => false, + ], + 'pagination_params' => [], + 'node_is_group' => false, + 'link_classes' => '', + 'paths' => ['a_path' => '', 'v_path' => '', 'pos' => 0], + 'node_icon' => '', + ]); + + self::assertStringContainsString('data-post=', $output); + self::assertStringNotContainsString('class="hover_show_full disableAjax"', $output); + } }