Skip to content
Permalink
Browse files

Retrieve parameters from $_POST in table relation

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information...
mauriciofauth committed Nov 3, 2018
1 parent d01ece6 commit d1d90b59b28ab8be332e442df55864cb858e40dd
@@ -72,7 +72,7 @@ function getDropdownValues ($dropdown) {
var $msgbox = PMA_ajaxShowMessage(); var $msgbox = PMA_ajaxShowMessage();
var $form = $dropdown.parents('form'); var $form = $dropdown.parents('form');
var argsep = PMA_commonParams.get('arg_separator'); var argsep = PMA_commonParams.get('arg_separator');
var url = 'tbl_relation.php?getDropdownValues=true' + argsep + 'ajax_request=true' + var params = 'getDropdownValues=true' + argsep + 'ajax_request=true' +
argsep + 'db=' + $form.find('input[name="db"]').val() + argsep + 'db=' + $form.find('input[name="db"]').val() +
argsep + 'table=' + $form.find('input[name="table"]').val() + argsep + 'table=' + $form.find('input[name="table"]').val() +
argsep + 'foreign=' + (foreign !== '') + argsep + 'foreign=' + (foreign !== '') +
@@ -82,11 +82,13 @@ function getDropdownValues ($dropdown) {
); );
var $server = $form.find('input[name="server"]'); var $server = $form.find('input[name="server"]');
if ($server.length > 0) { if ($server.length > 0) {
url += argsep + 'server=' + $form.find('input[name="server"]').val(); params += argsep + 'server=' + $form.find('input[name="server"]').val();
} }
$.ajax({ $.ajax({
url: url, type: 'POST',
datatype: 'json', url: 'tbl_relation.php',
data: params,
dataType: 'json',
success: function (data) { success: function (data) {
PMA_ajaxRemoveMessage($msgbox); PMA_ajaxRemoveMessage($msgbox);
if (typeof data !== 'undefined' && data.success) { if (typeof data !== 'undefined' && data.success) {
@@ -100,11 +100,11 @@ public function indexAction()
{ {
// Send table of column names to populate corresponding dropdowns depending // Send table of column names to populate corresponding dropdowns depending
// on the current selection // on the current selection
if (isset($_REQUEST['getDropdownValues']) if (isset($_POST['getDropdownValues'])
&& $_REQUEST['getDropdownValues'] === 'true' && $_POST['getDropdownValues'] === 'true'
) { ) {
// if both db and table are selected // if both db and table are selected
if (isset($_REQUEST['foreignTable'])) { if (isset($_POST['foreignTable'])) {
$this->getDropdownValueForTableAction(); $this->getDropdownValueForTableAction();
} else { // if only the db is selected } else { // if only the db is selected
$this->getDropdownValueForDbAction(); $this->getDropdownValueForDbAction();
@@ -241,8 +241,8 @@ public function updateForDisplayField()
*/ */
public function updateForForeignKeysAction() public function updateForForeignKeysAction()
{ {
$multi_edit_columns_name = isset($_REQUEST['foreign_key_fields_name']) $multi_edit_columns_name = isset($_POST['foreign_key_fields_name'])
? $_REQUEST['foreign_key_fields_name'] ? $_POST['foreign_key_fields_name']
: null; : null;
// (for now, one index name only; we keep the definitions if the // (for now, one index name only; we keep the definitions if the
@@ -260,7 +260,7 @@ public function updateForForeignKeysAction()
$this->response->addHTML($html); $this->response->addHTML($html);
// If there is a request for SQL previewing. // If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) { if (isset($_POST['preview_sql'])) {
Core::previewSQL($preview_sql_data); Core::previewSQL($preview_sql_data);
} }
@@ -282,8 +282,8 @@ public function updateForForeignKeysAction()
*/ */
public function updateForInternalRelationAction() public function updateForInternalRelationAction()
{ {
$multi_edit_columns_name = isset($_REQUEST['fields_name']) $multi_edit_columns_name = isset($_POST['fields_name'])
? $_REQUEST['fields_name'] ? $_POST['fields_name']
: null; : null;
if ($this->upd_query->updateInternalRelations( if ($this->upd_query->updateInternalRelations(
@@ -312,8 +312,8 @@ public function updateForInternalRelationAction()
*/ */
public function getDropdownValueForTableAction() public function getDropdownValueForTableAction()
{ {
$foreignTable = $_REQUEST['foreignTable']; $foreignTable = $_POST['foreignTable'];
$table_obj = $this->dbi->getTable($_REQUEST['foreignDb'], $foreignTable); $table_obj = $this->dbi->getTable($_POST['foreignDb'], $foreignTable);
// Since views do not have keys defined on them provide the full list of // Since views do not have keys defined on them provide the full list of
// columns // columns
if ($table_obj->isView()) { if ($table_obj->isView()) {
@@ -331,7 +331,7 @@ public function getDropdownValueForTableAction()
$this->response->addJSON('columns', $columns); $this->response->addJSON('columns', $columns);
// @todo should be: $server->db($db)->table($table)->primary() // @todo should be: $server->db($db)->table($table)->primary()
$primary = Index::getPrimary($foreignTable, $_REQUEST['foreignDb']); $primary = Index::getPrimary($foreignTable, $_POST['foreignDb']);
if (false === $primary) { if (false === $primary) {
return; return;
} }
@@ -348,11 +348,11 @@ public function getDropdownValueForTableAction()
public function getDropdownValueForDbAction() public function getDropdownValueForDbAction()
{ {
$tables = array(); $tables = array();
$foreign = isset($_REQUEST['foreign']) && $_REQUEST['foreign'] === 'true'; $foreign = isset($_POST['foreign']) && $_POST['foreign'] === 'true';
if ($foreign) { if ($foreign) {
$query = 'SHOW TABLE STATUS FROM ' $query = 'SHOW TABLE STATUS FROM '
. Util::backquote($_REQUEST['foreignDb']); . Util::backquote($_POST['foreignDb']);
$tables_rs = $this->dbi->query( $tables_rs = $this->dbi->query(
$query, $query,
DatabaseInterface::CONNECT_USER, DatabaseInterface::CONNECT_USER,
@@ -368,7 +368,7 @@ public function getDropdownValueForDbAction()
} }
} else { } else {
$query = 'SHOW TABLES FROM ' $query = 'SHOW TABLES FROM '
. Util::backquote($_REQUEST['foreignDb']); . Util::backquote($_POST['foreignDb']);
$tables_rs = $this->dbi->query( $tables_rs = $this->dbi->query(
$query, $query,
DatabaseInterface::CONNECT_USER, DatabaseInterface::CONNECT_USER,
@@ -36,8 +36,8 @@ protected function setUp()
$GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['PMA_PHP_SELF'] = 'index.php';
//$_SESSION //$_SESSION
$_REQUEST['foreignDb'] = 'db'; $_POST['foreignDb'] = 'db';
$_REQUEST['foreignTable'] = 'table'; $_POST['foreignTable'] = 'table';
$GLOBALS['dblist'] = new DataBasePMAMockForTblRelation(); $GLOBALS['dblist'] = new DataBasePMAMockForTblRelation();
$GLOBALS['dblist']->databases = new DataBaseMockForTblRelation(); $GLOBALS['dblist']->databases = new DataBaseMockForTblRelation();
@@ -202,7 +202,7 @@ function () {
array('tbl_storage_engine' => 'INNODB') array('tbl_storage_engine' => 'INNODB')
); );
$_REQUEST['foreign'] = 'true'; $_POST['foreign'] = 'true';
$ctrl->getDropdownValueForDbAction(); $ctrl->getDropdownValueForDbAction();
$json = $this->_response->getJSONResult(); $json = $this->_response->getJSONResult();
$this->assertEquals( $this->assertEquals(
@@ -248,7 +248,7 @@ function () {
array('tbl_storage_engine' => 'INNODB',) array('tbl_storage_engine' => 'INNODB',)
); );
$_REQUEST['foreign'] = 'false'; $_POST['foreign'] = 'false';
$ctrl->getDropdownValueForDbAction(); $ctrl->getDropdownValueForDbAction();
$json = $this->_response->getJSONResult(); $json = $this->_response->getJSONResult();
$this->assertEquals( $this->assertEquals(

0 comments on commit d1d90b5

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