Use the router for the server_variables.php page

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2019-07-12 21:10:24 -03:00
parent 5e20178f1f
commit e8c51f936d
13 changed files with 18 additions and 18 deletions

View File

@ -42,6 +42,9 @@ if (isset($_GET['route']) || isset($_POST['route'])) {
require_once ROOT_PATH . 'libraries/entry_points/server/status/queries.php';
});
});
$routes->addRoute(['GET', 'POST'], '/variables', function () {
require_once ROOT_PATH . 'libraries/entry_points/server/variables.php';
});
});
});
$routeInfo = $dispatcher->dispatch(

View File

@ -424,7 +424,7 @@ class Advisor
$rule['issue'] = $this->translate($rule['issue']);
// Replaces {server_variable} with 'server_variable'
// linking to server_variables.php
// linking to /server/variables
$rule['recommendation'] = preg_replace_callback(
'/\{([a-z_0-9]+)\}/Ui',
[
@ -470,7 +470,7 @@ class Advisor
*/
private function replaceVariable(array $matches): string
{
return '<a href="server_variables.php' . Url::getCommon(['filter' => $matches[1]])
return '<a href="' . Url::getFromRoute('/server/variables', ['filter' => $matches[1]])
. '">' . htmlspecialchars($matches[1]) . '</a>';
}

View File

@ -52,7 +52,6 @@ class Core
'server_status_advisor.php',
'server_status_monitor.php',
'server_status_variables.php',
'server_variables.php',
'sql.php',
'tbl_addfield.php',
'tbl_change.php',

View File

@ -645,7 +645,7 @@ class Menu
}
$tabs['vars']['icon'] = 's_vars';
$tabs['vars']['link'] = 'server_variables.php';
$tabs['vars']['link'] = Url::getFromRoute('/server/variables');
$tabs['vars']['text'] = __('Variables');
$tabs['charset']['icon'] = 's_asci';

View File

@ -151,7 +151,7 @@ class AuthenticationConfig extends AuthenticationPlugin
$GLOBALS['cfg']['DefaultTabServer'],
'server'
)
, Url::getCommon() , '" class="button disableAjax">'
, '" class="button disableAjax">'
, __('Retry to connect')
, '</a>' , "\n";
echo '</td>

View File

@ -38,7 +38,6 @@ class Sanitize
// possible return values from Util::getScriptNameForOption
'./index.php?',
'./server_status.php?',
'./server_variables.php?',
'./server_privileges.php?',
'./db_structure.php?',
'./db_sql.php?',

View File

@ -3183,13 +3183,13 @@ class Util
// Values for $cfg['DefaultTabServer']
switch ($target) {
case 'welcome':
return 'index.php';
return Url::getFromRoute('/');
case 'databases':
return Url::getFromRoute('/server/databases');
case 'status':
return 'server_status.php';
case 'variables':
return 'server_variables.php';
return Url::getFromRoute('/server/variables');
case 'privileges':
return 'server_privileges.php';
}

View File

@ -10,11 +10,11 @@ declare(strict_types=1);
use PhpMyAdmin\Controllers\Server\VariablesController;
use PhpMyAdmin\Response;
if (! defined('ROOT_PATH')) {
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
if (! defined('PHPMYADMIN')) {
exit;
}
require_once ROOT_PATH . 'libraries/common.inc.php';
global $containerBuilder;
/** @var VariablesController $controller */
$controller = $containerBuilder->get(VariablesController::class);

View File

@ -6,7 +6,7 @@
</h2>
{% if variables is not empty %}
<a href="server_variables.php{{ get_common() }}" class="ajax saveLink hide">
<a href="{{ get_url_from_route('/server/variables') }}" class="ajax saveLink hide">
{{ get_icon('b_save', 'Save'|trans) }}
</a>
<a href="#" class="cancelLink hide">
@ -80,4 +80,4 @@
{{ 'Not enough privilege to view server variables and settings. %s'|trans|format(
link_to_var_documentation('show_compatibility_56', is_mariadb)
)|error }}
{% endif %}
{% endif %}

View File

@ -211,8 +211,8 @@ class AdvisorTest extends PmaTestCase
'id' => 'Variable',
'name' => 'Variable',
'issue' => 'issue',
'recommendation' => 'Recommend <a href="server_variables.php?' .
'filter=status_var&amp;lang=en">status_var</a>',
'recommendation' => 'Recommend <a href="index.php?route=/server/variables&' .
'filter=status_var&lang=en">status_var</a>',
],
null,
],

View File

@ -99,7 +99,7 @@ class VariablesControllerTest extends TestCase
$html = $controller->index([]);
$this->assertStringContainsString(
'server_variables.php' . Url::getCommon(),
'index.php?route=/server/variables',
$html
);
$this->assertStringContainsString(

View File

@ -33,7 +33,6 @@ class CoreTest extends PmaTestCase
'pdf_pages.php',
'pdf_schema.php',
'server_binlog.php',
'server_variables.php',
'sql.php',
'tbl_select.php',
'transformation_overview.php',

View File

@ -132,7 +132,7 @@ class AuthenticationConfigTest extends PmaTestCase
);
$this->assertStringContainsString(
'<a href="index.php?server=0&amp;lang=en" '
'<a href="index.php?route=/&server=0&lang=en" '
. 'class="button disableAjax">Retry to connect</a>',
$html
);