diff --git a/db_qbe.php b/db_qbe.php index c96b75052426..5a74cc5176d5 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -82,7 +82,14 @@ $goto = 'db_sql.php'; // Parse and analyze the query - include_once 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); PMA_executeQueryAndSendQueryResponse( $analyzed_sql_results, // analyzed_sql_results diff --git a/import.php b/import.php index dcdb874563b1..b1179e39f1f4 100644 --- a/import.php +++ b/import.php @@ -732,7 +732,15 @@ // can choke on it so avoid parsing) $sqlLength = /*overload*/mb_strlen($sql_query); if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { - include_once 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); } // There was an error? @@ -755,8 +763,16 @@ $html_output = ''; foreach ($sql_queries as $sql_query) { + // parse sql query - include 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); $html_output .= PMA_executeQueryAndGetQueryResponse( $analyzed_sql_results, // analyzed_sql_results diff --git a/libraries/controllers/TableStructureController.php b/libraries/controllers/TableStructureController.php index b603b90964af..ade18fd3dc4b 100644 --- a/libraries/controllers/TableStructureController.php +++ b/libraries/controllers/TableStructureController.php @@ -801,9 +801,15 @@ protected function displayTableBrowseForSelectedColumns($goto, $pmaThemeImage) ); // Parse and analyze the query - // @todo Refactor parse_analyze.inc to protected function $db = &$this->db; - include_once 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); include_once 'libraries/sql.lib.php'; diff --git a/libraries/controllers/table/TableSearchController.php b/libraries/controllers/table/TableSearchController.php index f5b91fa78333..998d5553b5e7 100644 --- a/libraries/controllers/table/TableSearchController.php +++ b/libraries/controllers/table/TableSearchController.php @@ -528,7 +528,14 @@ public function doSelectionAction() /** * Parse and analyze the query */ - include_once 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); PMA_executeQueryAndSendQueryResponse( $analyzed_sql_results, // analyzed_sql_results diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index d17bc76275ec..71ea18e6f204 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -258,7 +258,14 @@ /** * Parse and analyze the query */ - include_once 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); PMA_executeQueryAndSendQueryResponse( $analyzed_sql_results, // analyzed_sql_results diff --git a/libraries/parse_analyze.inc.php b/libraries/parse_analyze.inc.php deleted file mode 100644 index 1bd9f46e6924..000000000000 --- a/libraries/parse_analyze.inc.php +++ /dev/null @@ -1,55 +0,0 @@ - 1) { - - /** - * @todo if there are more than one table name in the Select: - * - do not extract the first table name - * - do not show a table name in the page header - * - do not display the sub-pages links) - */ - $table = ''; - } else { - $table = $analyzed_sql_results['select_tables'][0][0]; - if (!empty($analyzed_sql_results['select_tables'][0][1])) { - $db = $analyzed_sql_results['select_tables'][0][1]; - } - } - - // There is no point checking if a reload is required if we already decided - // to reload. Also, no reload is required for AJAX requests. - if ((empty($reload)) && (empty($GLOBALS['is_ajax_request']))) { - // NOTE: Database names are case-insensitive. - $reload = strcasecmp($db, $prev_db) != 0; - } - - // Updating the array. - $analyzed_sql_results['reload'] = $reload; -} - -return $analyzed_sql_results; diff --git a/libraries/parse_analyze.lib.php b/libraries/parse_analyze.lib.php new file mode 100644 index 000000000000..7556742dba6d --- /dev/null +++ b/libraries/parse_analyze.lib.php @@ -0,0 +1,68 @@ + 1) { + + /** + * @todo if there are more than one table name in the Select: + * - do not extract the first table name + * - do not show a table name in the page header + * - do not display the sub-pages links) + */ + $table = ''; + } else { + $table = $analyzed_sql_results['select_tables'][0][0]; + if (!empty($analyzed_sql_results['select_tables'][0][1])) { + $db = $analyzed_sql_results['select_tables'][0][1]; + } + } + // There is no point checking if a reload is required if we already decided + // to reload. Also, no reload is required for AJAX requests. + if ((empty($reload)) && (empty($GLOBALS['is_ajax_request']))) { + // NOTE: Database names are case-insensitive. + $reload = strcasecmp($db, $prev_db) != 0; + } + + // Updating the array. + $analyzed_sql_results['reload'] = $reload; + } + + return array($analyzed_sql_results, $db, $table); +} diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 52769e16f587..263e8d9c4329 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -28,8 +28,14 @@ function PMA_parseAndAnalyze($sql_query, $db = null) $db = $GLOBALS['db']; } - // `$sql_query` is being used inside `parse_analyze.inc.php`. - return include 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + + return $analyzed_sql_results; } /** diff --git a/sql.php b/sql.php index eacfa0967823..a9b4a9979cd0 100644 --- a/sql.php +++ b/sql.php @@ -145,7 +145,14 @@ /** * Parse and analyze the query */ -require_once 'libraries/parse_analyze.inc.php'; +require_once 'libraries/parse_analyze.lib.php'; +list( + $analyzed_sql_results, + $db, + $table +) = PMA_parseAnalyze($sql_query, $db); +// @todo: possibly refactor +extract($analyzed_sql_results); /** diff --git a/tbl_row_action.php b/tbl_row_action.php index f5cf9e4f490d..22a9ba72f94b 100644 --- a/tbl_row_action.php +++ b/tbl_row_action.php @@ -153,7 +153,14 @@ /** * Parse and analyze the query */ - include_once 'libraries/parse_analyze.inc.php'; + include_once 'libraries/parse_analyze.lib.php'; + list( + $analyzed_sql_results, + $db, + $table + ) = PMA_parseAnalyze($sql_query, $db); + // @todo: possibly refactor + extract($analyzed_sql_results); PMA_executeQueryAndSendQueryResponse( $analyzed_sql_results, // analyzed_sql_results