From 9884a650da5125207b061698e9a235ddebfc6b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 3 Nov 2018 16:36:25 -0300 Subject: [PATCH] Retrieve parameters from $_POST in tbl_indexes.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/functions.js | 2 +- js/indexes.js | 5 +-- .../Table/TableIndexesController.php | 36 +++++++++---------- libraries/classes/Index.php | 2 +- tbl_indexes.php | 10 +++--- .../Table/TableIndexesControllerTest.php | 8 ++--- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/js/functions.js b/js/functions.js index cc29c17619..1e8aa42912 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3797,7 +3797,7 @@ function indexEditorDialog (url, title, callback_success, callback_failure) { $(this).dialog('close'); }; var $msgbox = PMA_ajaxShowMessage(); - $.get('tbl_indexes.php', url, function (data) { + $.post('tbl_indexes.php', url, function (data) { if (typeof data !== 'undefined' && data.success === false) { // in the case of an error, show the error message returned. PMA_ajaxShowMessage(data.error, false); diff --git a/js/indexes.js b/js/indexes.js index 19744833c9..dacdc2554f 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -660,10 +660,7 @@ AJAX.registerOnload('indexes.js', function () { title = PMA_messages.strAddIndex; } else { // Edit index - url = $(this).find('a').attr('href'); - if (url.substring(0, 16) === 'tbl_indexes.php?') { - url = url.substring(16, url.length); - } + url = $(this).find('a').getPostData(); title = PMA_messages.strEditIndex; } url += PMA_commonParams.get('arg_separator') + 'ajax_request=true'; diff --git a/libraries/classes/Controllers/Table/TableIndexesController.php b/libraries/classes/Controllers/Table/TableIndexesController.php index 68bddc65dd..080d292a1c 100644 --- a/libraries/classes/Controllers/Table/TableIndexesController.php +++ b/libraries/classes/Controllers/Table/TableIndexesController.php @@ -50,7 +50,7 @@ class TableIndexesController extends TableController */ public function indexAction() { - if (isset($_REQUEST['do_save_data'])) { + if (isset($_POST['do_save_data'])) { $this->doSaveDataAction(); return; } // end builds the new index @@ -67,24 +67,24 @@ class TableIndexesController extends TableController { $GLOBALS['dbi']->selectDb($GLOBALS['db']); $add_fields = 0; - if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) { + if (isset($_POST['index']) && is_array($_POST['index'])) { // coming already from form - if (isset($_REQUEST['index']['columns']['names'])) { - $add_fields = count($_REQUEST['index']['columns']['names']) + if (isset($_POST['index']['columns']['names'])) { + $add_fields = count($_POST['index']['columns']['names']) - $this->index->getColumnCount(); } - if (isset($_REQUEST['add_fields'])) { - $add_fields += $_REQUEST['added_fields']; + if (isset($_POST['add_fields'])) { + $add_fields += $_POST['added_fields']; } - } elseif (isset($_REQUEST['create_index'])) { - $add_fields = $_REQUEST['added_fields']; + } elseif (isset($_POST['create_index'])) { + $add_fields = $_POST['added_fields']; } // end preparing form values // Get fields and stores their name/type - if (isset($_REQUEST['create_edit_table'])) { - $fields = json_decode($_REQUEST['columns'], true); + if (isset($_POST['create_edit_table'])) { + $fields = json_decode($_POST['columns'], true); $index_params = array( - 'Non_unique' => ($_REQUEST['index']['Index_choice'] == 'UNIQUE') + 'Non_unique' => ($_POST['index']['Index_choice'] == 'UNIQUE') ? '0' : '1', ); $this->index->set($index_params); @@ -99,12 +99,12 @@ class TableIndexesController extends TableController 'table' => $this->table, ); - if (isset($_REQUEST['create_index'])) { + if (isset($_POST['create_index'])) { $form_params['create_index'] = 1; - } elseif (isset($_REQUEST['old_index'])) { - $form_params['old_index'] = $_REQUEST['old_index']; - } elseif (isset($_REQUEST['index'])) { - $form_params['old_index'] = $_REQUEST['index']; + } elseif (isset($_POST['old_index'])) { + $form_params['old_index'] = $_POST['old_index']; + } elseif (isset($_POST['index'])) { + $form_params['old_index'] = $_POST['index']; } $this->response->getHeader()->getScripts()->addFile('indexes.js'); @@ -116,7 +116,7 @@ class TableIndexesController extends TableController 'index' => $this->index, 'form_params' => $form_params, 'add_fields' => $add_fields, - 'create_edit_table' => isset($_REQUEST['create_edit_table']) + 'create_edit_table' => isset($_POST['create_edit_table']) ) ) ); @@ -137,7 +137,7 @@ class TableIndexesController extends TableController ->getSqlQueryForIndexCreateOrEdit($this->index, $error); // If there is a request for SQL previewing. - if (isset($_REQUEST['preview_sql'])) { + if (isset($_POST['preview_sql'])) { $this->response->addJSON( 'sql_data', diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php index c971e5b363..7836e1a77d 100644 --- a/libraries/classes/Index.php +++ b/libraries/classes/Index.php @@ -741,7 +741,7 @@ class Index $r .= '" ' . $row_span . '>' . ' ' . Util::getIcon('b_edit', __('Edit')) . '' . '' . "\n"; $this_params = $GLOBALS['url_params']; diff --git a/tbl_indexes.php b/tbl_indexes.php index a86d50d06b..76927ea1b0 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -27,15 +27,15 @@ $db = $container->get('db'); $table = $container->get('table'); $dbi = $container->get('dbi'); -if (!isset($_REQUEST['create_edit_table'])) { +if (!isset($_POST['create_edit_table'])) { include_once 'libraries/tbl_common.inc.php'; } -if (isset($_REQUEST['index'])) { - if (is_array($_REQUEST['index'])) { +if (isset($_POST['index'])) { + if (is_array($_POST['index'])) { // coming already from form - $index = new Index($_REQUEST['index']); + $index = new Index($_POST['index']); } else { - $index = $dbi->getTable($db, $table)->getIndex($_REQUEST['index']); + $index = $dbi->getTable($db, $table)->getIndex($_POST['index']); } } else { $index = new Index; diff --git a/test/classes/Controllers/Table/TableIndexesControllerTest.php b/test/classes/Controllers/Table/TableIndexesControllerTest.php index 5a22baf45a..85f9a43b27 100644 --- a/test/classes/Controllers/Table/TableIndexesControllerTest.php +++ b/test/classes/Controllers/Table/TableIndexesControllerTest.php @@ -111,7 +111,7 @@ class TableIndexesControllerTest extends PmaTestCase ); // Preview SQL - $_REQUEST['preview_sql'] = true; + $_POST['preview_sql'] = true; $ctrl->doSaveDataAction(); $jsonArray = $response->getJSONResult(); $this->assertArrayHasKey('sql_data', $jsonArray); @@ -123,7 +123,7 @@ class TableIndexesControllerTest extends PmaTestCase // Alter success $response->clear(); Response::getInstance()->setAjax(true); - unset($_REQUEST['preview_sql']); + unset($_POST['preview_sql']); $ctrl->doSaveDataAction(); $jsonArray = $response->getJSONResult(); $this->assertArrayHasKey('index_table', $jsonArray); @@ -169,8 +169,8 @@ class TableIndexesControllerTest extends PmaTestCase $index ); - $_REQUEST['create_index'] = true; - $_REQUEST['added_fields'] = 3; + $_POST['create_index'] = true; + $_POST['added_fields'] = 3; $ctrl->displayFormAction(); $html = $response->getHTMLResult();