From 0889b52c36c2800b240efaaa5cb003d16a5dc10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 26 Feb 2018 22:26:13 -0300 Subject: [PATCH] Replace static methods with instance methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace PhpMyAdmin\Sql static methods with instance methods. Signed-off-by: Maurício Meneghini Fauth --- db_qbe.php | 3 +- import.php | 10 +- .../Table/TableSearchController.php | 3 +- .../Table/TableStructureController.php | 3 +- .../classes/Database/MultiTableQuery.php | 3 +- libraries/classes/Display/Results.php | 4 +- libraries/classes/MultSubmits.php | 3 +- libraries/classes/Sql.php | 284 +++++++++--------- libraries/mult_submits.inc.php | 3 +- sql.php | 20 +- tbl_row_action.php | 3 +- test/classes/SqlTest.php | 155 ++++++---- 12 files changed, 272 insertions(+), 222 deletions(-) diff --git a/db_qbe.php b/db_qbe.php index d49d01cd72..df143faaaf 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -85,7 +85,8 @@ if (isset($_REQUEST['submit_sql']) && ! empty($sql_query)) { $message_to_display = true; } else { $goto = 'db_sql.php'; - Sql::executeQueryAndSendQueryResponse( + $sql = new Sql(); + $sql->executeQueryAndSendQueryResponse( null, // analyzed_sql_results false, // is_gotofile $_REQUEST['db'], // db diff --git a/import.php b/import.php index f83d03e295..958b60673b 100644 --- a/import.php +++ b/import.php @@ -41,6 +41,8 @@ if (isset($_REQUEST['simulate_dml'])) { $response = Response::getInstance(); +$sql = new Sql(); + // If it's a refresh console bookmarks request if (isset($_REQUEST['console_bookmark_refresh'])) { $response->addJSON( @@ -697,7 +699,7 @@ if ($go_sql) { extract($analyzed_sql_results); // Check if User is allowed to issue a 'DROP DATABASE' Statement - if (Sql::hasNoRightsToDropDatabase( + if ($sql->hasNoRightsToDropDatabase( $analyzed_sql_results, $cfg['AllowUserDropDatabase'], $GLOBALS['dbi']->isSuperuser() )) { PhpMyAdmin\Util::mysqlDie( @@ -713,7 +715,7 @@ if ($go_sql) { $table = $table_from_sql; } - $html_output .= Sql::executeQueryAndGetQueryResponse( + $html_output .= $sql->executeQueryAndGetQueryResponse( $analyzed_sql_results, // analyzed_sql_results false, // is_gotofile $db, // db @@ -740,7 +742,7 @@ if ($go_sql) { // the SQL tab if (! empty($_POST['bkm_label']) && ! empty($import_text)) { $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']); - Sql::storeTheQueryAsBookmark( + $sql->storeTheQueryAsBookmark( $db, $cfgBookmark['user'], $_POST['sql_query'], $_POST['bkm_label'], isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null @@ -755,7 +757,7 @@ if ($go_sql) { // Save a Bookmark with more than one queries (if Bookmark label given). if (! empty($_POST['bkm_label']) && ! empty($import_text)) { $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']); - Sql::storeTheQueryAsBookmark( + $sql->storeTheQueryAsBookmark( $db, $cfgBookmark['user'], $_POST['sql_query'], $_POST['bkm_label'], isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null diff --git a/libraries/classes/Controllers/Table/TableSearchController.php b/libraries/classes/Controllers/Table/TableSearchController.php index 51567b678c..c1f8e3be72 100644 --- a/libraries/classes/Controllers/Table/TableSearchController.php +++ b/libraries/classes/Controllers/Table/TableSearchController.php @@ -455,7 +455,8 @@ class TableSearchController extends TableController */ $db = $this->db; - Sql::executeQueryAndSendQueryResponse( + $sql = new Sql(); + $sql->executeQueryAndSendQueryResponse( null, // analyzed_sql_results false, // is_gotofile $this->db, // db diff --git a/libraries/classes/Controllers/Table/TableStructureController.php b/libraries/classes/Controllers/Table/TableStructureController.php index 3db699d808..a6516e194e 100644 --- a/libraries/classes/Controllers/Table/TableStructureController.php +++ b/libraries/classes/Controllers/Table/TableStructureController.php @@ -820,8 +820,9 @@ class TableStructureController extends TableController // @todo: possibly refactor extract($analyzed_sql_results); + $sql = new Sql(); $this->response->addHTML( - Sql::executeQueryAndGetQueryResponse( + $sql->executeQueryAndGetQueryResponse( isset($analyzed_sql_results) ? $analyzed_sql_results : '', false, // is_gotofile $this->db, // db diff --git a/libraries/classes/Database/MultiTableQuery.php b/libraries/classes/Database/MultiTableQuery.php index d2f23d9dd6..a1b1f745db 100644 --- a/libraries/classes/Database/MultiTableQuery.php +++ b/libraries/classes/Database/MultiTableQuery.php @@ -110,7 +110,8 @@ class MultiTableQuery extract($analyzedSqlResults); $goto = 'db_multi_table_query.php'; - Sql::executeQueryAndSendQueryResponse( + $sql = new Sql(); + $sql->executeQueryAndSendQueryResponse( null, // analyzed_sql_results false, // is_gotofile $db, // db diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index c2dd2f05e7..c386670403 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -1406,7 +1406,6 @@ class Results . Url::getHiddenInputs( $this->__get('db'), $this->__get('table') ) - // to avoid calling Sql::handleSortOrder() later . Url::getHiddenFields(array('sort_by_key' => '1')) . __('Sort by key') . ': ' . $dropdown . ''; return $dropdown; } @@ -432,7 +432,7 @@ EOT; * * @return string with value */ - public static function getFullValuesForSetColumn($db, $table, $column, $where_clause) + private function getFullValuesForSetColumn($db, $table, $column, $where_clause) { $result = $GLOBALS['dbi']->fetchSingleRow( "SELECT `$column` FROM `$db`.`$table` WHERE $where_clause" @@ -453,9 +453,9 @@ EOT; * * @return string $dropdown html for the set column */ - public static function getHtmlForSetColumn($db, $table, $column, $curr_value) + private function getHtmlForSetColumn($db, $table, $column, $curr_value) { - $values = self::getValuesForColumn($db, $table, $column); + $values = $this->getValuesForColumn($db, $table, $column); $dropdown = ''; $full_values = isset($_REQUEST['get_full_values']) ? $_REQUEST['get_full_values'] : false; @@ -465,7 +465,7 @@ EOT; // If the $curr_value was truncated, we should // fetch the correct full values from the table if ($full_values && ! empty($where_clause)) { - $curr_value = self::getFullValuesForSetColumn( + $curr_value = $this->getFullValuesForSetColumn( $db, $table, $column, $where_clause ); } @@ -477,7 +477,7 @@ EOT; $selected_values = explode(',', $converted_curr_value); - $dropdown .= self::getHtmlForOptionsList($values, $selected_values); + $dropdown .= $this->getHtmlForOptionsList($values, $selected_values); $select_size = (sizeof($values) > 10) ? 10 : sizeof($values); $dropdown = '