Merge pull request #20291 from predictor2718/fix/20253-missing-db-on-index-nav
Fix #20253 - Missing parameter: db when clicking on index in tree
This commit is contained in:
commit
632e5be35b
@ -36,7 +36,11 @@
|
||||
{% if node_is_container %}
|
||||
<a class="hover_show_full disableAjax" href="{{ url(text_link.route, text_link.params) }}">{{ node.name }}</a>
|
||||
{% elseif 'index' in node.classes %}
|
||||
<a class="hover_show_full disableAjax" href="{{ url(text_link.route) }}" data-post="{{ get_common(text_link.params|merge({'is_from_nav': true})) }}" title="{{ text_link.title }}">
|
||||
{# 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". #}
|
||||
<a class="hover_show_full" href="{{ url(text_link.route) }}" data-post="{{ get_common(text_link.params|merge({'is_from_nav': true})) }}" title="{{ text_link.title }}">
|
||||
{{- displayName -}}
|
||||
</a>
|
||||
{% else %}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user