From d745d1ce019bf1aa60f19e8ac993389adb81e3a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 10 Nov 2018 19:27:39 -0200 Subject: [PATCH] Retrieve parameters from $_POST in Table class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- libraries/classes/Table.php | 30 +++++++++++++++--------------- test/classes/TableTest.php | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index 976cf31ceead..b1e4ab088aa3 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -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' ) { /** @@ -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]; @@ -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 @@ -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 @@ -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(); @@ -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(); @@ -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 { diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index 99e7352c6d16..f6fe22c8208d 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -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); @@ -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,