Skip to content

Commit

Permalink
Retrieve parameters from $_POST in Table class
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Nov 10, 2018
1 parent c36592b commit d745d1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions libraries/classes/Table.php
Expand Up @@ -986,8 +986,8 @@ public static function moveCopy($source_db, $source_table, $target_db,
// Phase 1: Dropping existent element of the same name (if exists
// and required).

if (isset($_REQUEST['drop_if_exists'])
&& $_REQUEST['drop_if_exists'] == 'true'
if (isset($_POST['drop_if_exists'])
&& $_POST['drop_if_exists'] == 'true'
) {

/**
Expand Down Expand Up @@ -1840,7 +1840,7 @@ public function getUiProp($property)
return false;
}

if (!isset($_REQUEST['discard_remembered_sort'])) {
if (!isset($_POST['discard_remembered_sort'])) {
// check if the column name exists in this table
$tmp = explode(' ', $this->uiprefs[$property]);
$colname = $tmp[0];
Expand Down Expand Up @@ -2044,13 +2044,13 @@ public function getSqlQueryForIndexCreateOrEdit($index, &$error)
);

// Drops the old index
if (! empty($_REQUEST['old_index'])) {
if ($_REQUEST['old_index'] == 'PRIMARY') {
if (! empty($_POST['old_index'])) {
if ($_POST['old_index'] == 'PRIMARY') {
$sql_query .= ' DROP PRIMARY KEY,';
} else {
$sql_query .= sprintf(
' DROP INDEX %s,',
Util::backquote($_REQUEST['old_index'])
Util::backquote($_POST['old_index'])
);
}
} // end if
Expand Down Expand Up @@ -2339,9 +2339,9 @@ public function updateForeignKeys(array $destination_foreign_db,
|| $existrel_foreign[$master_field_md5]['ref_table_name'] != $foreign_table
|| $existrel_foreign[$master_field_md5]['ref_index_list'] != $foreign_field
|| $existrel_foreign[$master_field_md5]['index_list'] != $master_field
|| $_REQUEST['constraint_name'][$master_field_md5] != $constraint_name
|| ($_REQUEST['on_delete'][$master_field_md5] != $on_delete)
|| ($_REQUEST['on_update'][$master_field_md5] != $on_update)
|| $_POST['constraint_name'][$master_field_md5] != $constraint_name
|| ($_POST['on_delete'][$master_field_md5] != $on_delete)
|| ($_POST['on_update'][$master_field_md5] != $on_update)
) {
// another foreign key is already defined for this field
// or an option has been changed for ON DELETE or ON UPDATE
Expand All @@ -2365,7 +2365,7 @@ public function updateForeignKeys(array $destination_foreign_db,
)
. ';';

if (! isset($_REQUEST['preview_sql'])) {
if (! isset($_POST['preview_sql'])) {
$display_query .= $drop_query . "\n";
$this->_dbi->tryQuery($drop_query);
$tmp_error_drop = $this->_dbi->getError();
Expand All @@ -2388,12 +2388,12 @@ public function updateForeignKeys(array $destination_foreign_db,

$create_query = $this->_getSQLToCreateForeignKey(
$table, $master_field, $foreign_db, $foreign_table, $foreign_field,
$_REQUEST['constraint_name'][$master_field_md5],
$options_array[$_REQUEST['on_delete'][$master_field_md5]],
$options_array[$_REQUEST['on_update'][$master_field_md5]]
$_POST['constraint_name'][$master_field_md5],
$options_array[$_POST['on_delete'][$master_field_md5]],
$options_array[$_POST['on_update'][$master_field_md5]]
);

if (! isset($_REQUEST['preview_sql'])) {
if (! isset($_POST['preview_sql'])) {
$display_query .= $create_query . "\n";
$this->_dbi->tryQuery($create_query);
$tmp_error_create = $this->_dbi->getError();
Expand Down Expand Up @@ -2439,7 +2439,7 @@ public function updateForeignKeys(array $destination_foreign_db,
$options_array[$existrel_foreign[$master_field_md5]['on_delete']],
$options_array[$existrel_foreign[$master_field_md5]['on_update']]
);
if (! isset($_REQUEST['preview_sql'])) {
if (! isset($_POST['preview_sql'])) {
$display_query .= $sql_query_recreate . "\n";
$this->_dbi->tryQuery($sql_query_recreate);
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/classes/TableTest.php
Expand Up @@ -961,7 +961,7 @@ public function testGetSqlQueryForIndexCreateOrEdit()
$index = new Index();
$error = false;

$_REQUEST['old_index'] = "PRIMARY";
$_POST['old_index'] = "PRIMARY";

$table = new Table($table, $db);
$sql = $table->getSqlQueryForIndexCreateOrEdit($index, $error);
Expand Down Expand Up @@ -1163,7 +1163,7 @@ public function testMoveCopy()
$GLOBALS['dbi']->expects($this->any())->method('getTable')
->will($this->returnValue(new Table($target_table, $target_db)));

$_REQUEST['drop_if_exists'] = true;
$_POST['drop_if_exists'] = true;

$return = Table::moveCopy(
$source_db, $source_table, $target_db,
Expand Down

0 comments on commit d745d1c

Please sign in to comment.