Skip to content
Permalink
Browse files

Use the router for the database operations page

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information...
mauriciofauth committed Jul 24, 2019
1 parent f396c04 commit 469fd5c05c35f2eab9b566b4ed59531fe0ec4683
@@ -26,6 +26,9 @@
require_once ROOT_PATH . 'libraries/entry_points/home.php';
});
$routes->addGroup('/database', function (RouteCollector $routes) {
$routes->addRoute(['GET', 'POST'], '/operations', function () {
require_once ROOT_PATH . 'libraries/entry_points/database/operations.php';
});
$routes->addRoute(['GET', 'POST'], '/search', function () {
require_once ROOT_PATH . 'libraries/entry_points/database/search.php';
});
@@ -10,7 +10,7 @@
*/

/**
* Ajax event handlers here for db_operations.php
* Ajax event handlers here for /database/operations
*
* Actions Ajaxified here:
* Rename Database
@@ -2844,7 +2844,7 @@ AJAX.registerTeardown('functions.js', function () {
});

/**
* jQuery coding for 'Create Table'. Used on db_operations.php,
* jQuery coding for 'Create Table'. Used on /database/operations,
* /database/structure and /database/tracking (i.e., wherever
* PhpMyAdmin\Display\CreateTable is used)
*
@@ -34,7 +34,6 @@ class Core
'db_multi_table_query.php',
'db_qbe.php',
'db_import.php',
'db_operations.php',
'db_routines.php',
'export.php',
'import.php',
@@ -1230,7 +1230,7 @@ public function buildSql(
$params = ['db' => $db_name];
$db_url = Url::getFromRoute('/database/structure', $params);
$db_ops_url = 'db_operations.php' . Url::getCommon($params);
$db_ops_url = Url::getFromRoute('/database/operations', $params);
$message = '<br><br>';
$message .= '<strong>' . __(
@@ -497,7 +497,7 @@ private function _getDbTabs()
$tabs['import']['text'] = __('Import');
$tabs['import']['icon'] = 'b_import';
$tabs['operation']['link'] = 'db_operations.php';
$tabs['operation']['link'] = Url::getFromRoute('/database/operations');
$tabs['operation']['text'] = __('Operations');
$tabs['operation']['icon'] = 'b_tblops';
@@ -52,7 +52,7 @@ public function __construct($name, $type = Node::OBJECT, $isGroup = false)
'text' => $scriptName . ($hasRoute === false ? '?' : '&')
. 'server=' . $GLOBALS['server']
. '&amp;db=%1$s',
'icon' => 'db_operations.php?server=' . $GLOBALS['server']
'icon' => Url::getFromRoute('/database/operations') . '&amp;server=' . $GLOBALS['server']
. '&amp;db=%1$s&amp;',
'title' => __('Structure'),
];
@@ -53,7 +53,9 @@ public function __construct(DatabaseInterface $dbi, Relation $relation)
public function getHtmlForDatabaseComment($db)
{
$html_output = '<div>'
. '<form method="post" action="db_operations.php" id="formDatabaseComment">'
. '<form method="post" action="'
. Url::getFromRoute('/database/operations')
. '" id="formDatabaseComment">'
. Url::getHiddenInputs($db)
. '<fieldset>'
. '<legend>';
@@ -88,8 +90,8 @@ public function getHtmlForRenameDatabase($db, $db_collation)
$html_output = '<div>'
. '<form id="rename_db_form" '
. 'class="ajax" '
. 'method="post" action="db_operations.php" '
. 'onsubmit="return Functions.emptyCheckTheField(this, \'newname\')">';
. 'method="post" action="' . Url::getFromRoute('/database/operations')
. '" onsubmit="return Functions.emptyCheckTheField(this, \'newname\')">';
if ($db_collation !== null) {
$html_output .= '<input type="hidden" name="db_collation" '
. 'value="' . $db_collation
@@ -153,7 +155,7 @@ public function getHtmlForDropDatabaseLink($db)
$this_sql_query = 'DROP DATABASE ' . Util::backquote($db);
$this_url_params = [
'sql_query' => $this_sql_query,
'back' => 'db_operations.php',
'back' => Url::getFromRoute('/database/operations'),
'goto' => 'index.php',
'reload' => '1',
'purge' => '1',
@@ -207,8 +209,8 @@ public function getHtmlForCopyDatabase($db, $db_collation)
$html_output = '<div>';
$html_output .= '<form id="copy_db_form" '
. 'class="ajax" '
. 'method="post" action="db_operations.php" '
. 'onsubmit="return Functions.emptyCheckTheField(this, \'newname\')">';
. 'method="post" action="' . Url::getFromRoute('/database/operations')
. '" onsubmit="return Functions.emptyCheckTheField(this, \'newname\')">';
if ($db_collation !== null) {
$html_output .= '<input type="hidden" name="db_collation" '
@@ -299,7 +301,7 @@ public function getHtmlForChangeDatabaseCharset($db, $db_collation)
$html_output = '<div>'
. '<form id="change_db_charset_form" ';
$html_output .= 'class="ajax" ';
$html_output .= 'method="post" action="db_operations.php">';
$html_output .= 'method="post" action="' . Url::getFromRoute('/database/operations') . '">';
$html_output .= Url::getHiddenInputs($db);
@@ -123,7 +123,7 @@ public function __construct()
);
/**
* The following methods are used in export.php or in db_operations.php,
* The following methods are used in export.php or in /database/operations,
* but they are not implemented by all export plugins
*/
@@ -2105,18 +2105,22 @@ public function getHtmlFixPmaTables($allTables, $createDb = false)
{
$retval = '';
$url_query = Url::getCommon(['db' => $GLOBALS['db']], '');
$params = [
'db' => $GLOBALS['db'],
'goto' => Url::getFromRoute('/database/operations'),
];
if ($allTables) {
if ($createDb) {
$url_query .= '&amp;goto=db_operations.php&amp;create_pmadb=1';
$params['create_pmadb'] = 1;
$message = Message::notice(
__(
'%sCreate%s a database named \'phpmyadmin\' and setup '
. 'the phpMyAdmin configuration storage there.'
)
);
} else {
$url_query .= '&amp;goto=db_operations.php&amp;fixall_pmadb=1';
$params['fixall_pmadb'] = 1;
$message = Message::notice(
__(
'%sCreate%s the phpMyAdmin configuration storage in the '
@@ -2125,12 +2129,14 @@ public function getHtmlFixPmaTables($allTables, $createDb = false)
);
}
} else {
$url_query .= '&amp;goto=db_operations.php&amp;fix_pmadb=1';
$params['fix_pmadb'] = 1;
$message = Message::notice(
__('%sCreate%s missing phpMyAdmin configuration storage tables.')
);
}
$message->addParamHtml('<a href="./chk_rel.php" data-post="' . $url_query . '">');
$message->addParamHtml(
'<a href="./chk_rel.php" data-post="' . Url::getCommon($params, '') . '">'
);
$message->addParamHtml('</a>');
$retval .= $message->getDisplay();
@@ -38,7 +38,6 @@ public static function checkLink($url, $http = false, $other = false)
// possible return values from Util::getScriptNameForOption
'./index.php?',
'./db_sql.php?',
'./db_operations.php?',
'./tbl_sql.php?',
'./tbl_select.php?',
'./tbl_change.php?',
@@ -3195,7 +3195,7 @@ public static function getScriptNameForOption($target, $location)
case 'search':
return Url::getFromRoute('/database/search');
case 'operations':
return 'db_operations.php';
return Url::getFromRoute('/database/operations');
}
} elseif ($location == 'table') {
// Values for $cfg['DefaultTabTable'],
@@ -130,7 +130,7 @@
/**
* If we are in an Ajax request, let us stop the execution here. Necessary for
* db charset change action on db_operations.php. If this causes a bug on
* db charset change action on /database/operations. If this causes a bug on
* other pages, we might have to move this to a different location.
*/
if ($response->isAjax()) {
@@ -23,15 +23,14 @@
use PhpMyAdmin\Relation;
use PhpMyAdmin\RelationCleanup;
use PhpMyAdmin\Response;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
if (! defined('ROOT_PATH')) {
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
if (! defined('PHPMYADMIN')) {
exit;
}
global $cfg, $db, $server, $url_query;
require_once ROOT_PATH . 'libraries/common.inc.php';
global $cfg, $containerBuilder, $db, $server, $url_query;
/** @var Response $response */
$response = $containerBuilder->get(Response::class);
@@ -236,7 +235,9 @@
}
require ROOT_PATH . 'libraries/db_common.inc.php';
$url_query .= '&amp;goto=db_operations.php';
$url_params['goto'] = Url::getFromRoute('/database/operations');
$url_query .= Url::getCommon($url_params, '&');
// Gets the database structure
$sub_part = '_structure';
@@ -363,7 +363,9 @@
if (isset($_GET['viewing_mode']) && $_GET['viewing_mode'] == 'db') {
$db = $_REQUEST['db'] = $_GET['checkprivsdb'];
$url_query .= '&amp;goto=db_operations.php';
$url_query .= Url::getCommon([
'goto' => Url::getFromRoute('/database/operations'),
], '&');
// Gets the database structure
$sub_part = '_structure';
@@ -469,7 +469,7 @@
$url_params,
[
'sql_query' => $this_sql_query,
'goto' => 'db_operations.php',
'goto' => Url::getFromRoute('/database/operations'),
'reload' => '1',
'purge' => '1',
'message_to_show' => sprintf(
@@ -66,7 +66,7 @@ public function testGetHtmlForDatabaseComment()
{
$this->assertRegExp(
'/.*db_operations.php(.|[\n])*Database comment.*name="comment"([\n]|.)*/m',
'/.*\/database\/operations(.|[\n])*Database comment.*name="comment"([\n]|.)*/m',
$this->operations->getHtmlForDatabaseComment("pma")
);
}
@@ -81,7 +81,7 @@ public function testGetHtmlForRenameDatabase()
$db_collation = 'db1';
$html = $this->operations->getHtmlForRenameDatabase("pma", $db_collation);
$this->assertStringContainsString('db_operations.php', $html);
$this->assertStringContainsString('index.php?route=/database/operations', $html);
$this->assertRegExp(
'/.*db_rename.*Rename database to.*/',
$html
@@ -97,7 +97,7 @@ public function testGetHtmlForDropDatabaseLink()
{
$this->assertRegExp(
'/.*DROP.DATABASE.*db_operations.php.*Drop the database.*/',
'/.*DROP.DATABASE.*%2Fdatabase%2Foperations.*Drop the database.*/',
$this->operations->getHtmlForDropDatabaseLink("pma")
);
}
@@ -111,7 +111,7 @@ public function testGetHtmlForCopyDatabase()
{
$db_collation = 'db1';
$html = $this->operations->getHtmlForCopyDatabase("pma", $db_collation);
$this->assertRegExp('/.*db_operations.php.*/', $html);
$this->assertRegExp('/.*\/database\/operations.*/', $html);
$this->assertRegExp('/.*db_copy.*/', $html);
$this->assertRegExp('/.*Copy database to.*/', $html);
}
@@ -131,7 +131,7 @@ public function testGetHtmlForChangeDatabaseCharset()
$result
);
$this->assertRegExp(
'/.*db_operations.php.*/',
'/.*\/database\/operations.*/',
$result
);
}

0 comments on commit 469fd5c

Please sign in to comment.
You can’t perform that action at this time.