' . "\n"
- . htmlspecialchars($queryBase, ENT_COMPAT) . '
';
} else {
- $queryBase = self::formatSql($queryBase);
+ $queryBase = self::formatSql($sqlQuery, true);
}
// Prepares links that may be displayed to edit/explain the query
@@ -507,6 +490,7 @@ class Generator
// but only explain a SELECT (that has not been explained)
/* SQL-Parser-Analyzer */
$explainLink = '';
+ $queryTooBig = mb_strlen($sqlQuery) > $config->settings['MaxCharactersInDisplayedSQL'];
$isSelect = preg_match('@^SELECT[[:space:]]+@i', $sqlQuery);
if (! empty($config->settings['SQLQuery']['Explain']) && ! $queryTooBig) {
$explainParams = $urlParams;
@@ -1085,8 +1069,6 @@ class Generator
* @param bool $truncate truncate the query if it is too long
*
* @return string the formatted sql
- *
- * @global array $cfg the configuration array
*/
public static function formatSql(string $sqlQuery, bool $truncate = false): string
{
diff --git a/src/Import/Import.php b/src/Import/Import.php
index 19a20a8d2b..dfef41c653 100644
--- a/src/Import/Import.php
+++ b/src/Import/Import.php
@@ -240,13 +240,6 @@ class Import
// Do we have something to push into buffer?
$this->importRunBuffer = $sql !== '' ? $sql . ';' : null;
-
- // In case of ROLLBACK, notify the user.
- if (! isset($_POST['rollback_query'])) {
- return;
- }
-
- ImportSettings::$message .= __('[ROLLBACK occurred.]');
}
/**
@@ -928,20 +921,10 @@ class Import
ImportSettings::$importNotice = $message;
}
- /**
- * Handles request for ROLLBACK.
- *
- * @param string $sqlQuery SQL query(s)
- */
public function handleRollbackRequest(string $sqlQuery): void
{
$sqlDelimiter = $_POST['sql_delimiter'];
$queries = explode($sqlDelimiter, $sqlQuery);
- $error = false;
- $errorMsg = __(
- 'Only INSERT, UPDATE, DELETE and REPLACE '
- . 'SQL queries containing transactional engine tables can be rolled back.',
- );
$dbi = DatabaseInterface::getInstance();
foreach ($queries as $sqlQuery) {
if ($sqlQuery === '') {
@@ -953,17 +936,14 @@ class Import
continue;
}
- $globalError = $dbi->getError();
- $error = $globalError !== '' ? $globalError : $errorMsg;
+ $sqlError = $dbi->getError();
+ $error = $sqlError !== '' ? $sqlError : __(
+ 'Only INSERT, UPDATE, DELETE and REPLACE '
+ . 'SQL queries containing transactional engine tables can be rolled back.',
+ );
- break;
- }
-
- if ($error) {
- unset($_POST['rollback_query']);
$response = ResponseRenderer::getInstance();
- $message = Message::rawError($error);
- $response->addJSON('message', $message);
+ $response->addJSON('message', Message::rawError($error));
$response->callExit();
}
diff --git a/src/ParseAnalyze.php b/src/ParseAnalyze.php
index 948d4a8d35..61e88e3b65 100644
--- a/src/ParseAnalyze.php
+++ b/src/ParseAnalyze.php
@@ -26,9 +26,6 @@ class ParseAnalyze
*/
public static function sqlQuery(string $sqlQuery, string $db): array
{
- // @todo: move to returned results (also in all the calling chain)
- $GLOBALS['unparsed_sql'] = $sqlQuery;
-
$info = Query::getAll($sqlQuery);
$table = '';
diff --git a/tests/unit/Html/GeneratorTest.php b/tests/unit/Html/GeneratorTest.php
index 97badffb91..390deba9b4 100644
--- a/tests/unit/Html/GeneratorTest.php
+++ b/tests/unit/Html/GeneratorTest.php
@@ -476,7 +476,6 @@ class GeneratorTest extends AbstractTestCase
{
Config::getInstance()->settings['ShowSQL'] = true;
$GLOBALS['display_query'] = null;
- $GLOBALS['unparsed_sql'] = null;
$GLOBALS['sql_query'] = 'SELECT 1;';
$usingBookmarkMessage = Message::notice('Bookmark message');
$GLOBALS['using_bookmark_message'] = $usingBookmarkMessage;
@@ -533,7 +532,6 @@ HTML;
$config->settings['SQLQuery']['Edit'] = false;
$config->settings['SQLQuery']['Refresh'] = true;
$GLOBALS['display_query'] = 'EXPLAIN SELECT 1;';
- $GLOBALS['unparsed_sql'] = null;
$GLOBALS['sql_query'] = null;
DatabaseInterface::$instance = $this->createDatabaseInterface();
Current::$database = 'test_db';
diff --git a/tests/unit/ParseAnalyzeTest.php b/tests/unit/ParseAnalyzeTest.php
index 0de673be2d..8019facfdb 100644
--- a/tests/unit/ParseAnalyzeTest.php
+++ b/tests/unit/ParseAnalyzeTest.php
@@ -24,12 +24,8 @@ class ParseAnalyzeTest extends AbstractTestCase
$GLOBALS['lang'] = 'en';
ResponseRenderer::getInstance()->setAjax(false);
- $GLOBALS['unparsed_sql'] = '';
-
$actual = ParseAnalyze::sqlQuery('SELECT * FROM `sakila`.`actor`', 'sakila_test');
- /** @psalm-suppress TypeDoesNotContainType */
- self::assertSame('SELECT * FROM `sakila`.`actor`', $GLOBALS['unparsed_sql']);
self::assertSame('sakila', $actual[1]);
self::assertSame('actor', $actual[2]);
self::assertTrue($actual[0]->flags->reload);
@@ -44,12 +40,8 @@ class ParseAnalyzeTest extends AbstractTestCase
$GLOBALS['lang'] = 'en';
ResponseRenderer::getInstance()->setAjax(false);
- $GLOBALS['unparsed_sql'] = '';
-
$actual = ParseAnalyze::sqlQuery('SELECT `first_name`, `title` FROM `actor`, `film`', 'sakila');
- /** @psalm-suppress TypeDoesNotContainType */
- self::assertSame('SELECT `first_name`, `title` FROM `actor`, `film`', $GLOBALS['unparsed_sql']);
self::assertSame('sakila', $actual[1]);
self::assertSame('', $actual[2]);
self::assertFalse($actual[0]->flags->reload);