Fixes: #17482 Pull-request: #17906 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
7fb122ac27
@ -61,7 +61,7 @@
|
||||
"paragonie/sodium_compat": "^1.17",
|
||||
"phpmyadmin/motranslator": "^5.0",
|
||||
"phpmyadmin/shapefile": "^3.0.1",
|
||||
"phpmyadmin/sql-parser": "dev-master#a9cd167be77829ec2dd4496ce1010ed6abde92f8",
|
||||
"phpmyadmin/sql-parser": "dev-master#8fddb4becdfb657db3b9ade52e952ef3c822a26b",
|
||||
"phpmyadmin/twig-i18n-extension": "^4.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
|
||||
@ -3443,12 +3443,14 @@ class Results
|
||||
* Checks the posted options for viewing query results
|
||||
* and sets appropriate values in the session.
|
||||
*
|
||||
* @param array $analyzedSqlResults the analyzed query results
|
||||
*
|
||||
* @todo make maximum remembered queries configurable
|
||||
* @todo move/split into SQL class!?
|
||||
* @todo currently this is called twice unnecessary
|
||||
* @todo ignore LIMIT and ORDER in query!?
|
||||
*/
|
||||
public function setConfigParamsForDisplayTable(): void
|
||||
public function setConfigParamsForDisplayTable(array $analyzedSqlResults): void
|
||||
{
|
||||
$sqlMd5 = md5($this->properties['server'] . $this->properties['db'] . $this->properties['sql_query']);
|
||||
$query = [];
|
||||
@ -3482,6 +3484,9 @@ class Results
|
||||
$query['pos'] = 0;
|
||||
}
|
||||
|
||||
// Full text is needed in case of explain statements, if not specified.
|
||||
$fullText = $analyzedSqlResults['is_explain'];
|
||||
|
||||
if (
|
||||
isset($_REQUEST['pftext']) && in_array(
|
||||
$_REQUEST['pftext'],
|
||||
@ -3490,6 +3495,8 @@ class Results
|
||||
) {
|
||||
$query['pftext'] = $_REQUEST['pftext'];
|
||||
unset($_REQUEST['pftext']);
|
||||
} elseif ($fullText) {
|
||||
$query['pftext'] = self::DISPLAY_FULL_TEXT;
|
||||
} elseif (empty($query['pftext'])) {
|
||||
$query['pftext'] = self::DISPLAY_PARTIAL_TEXT;
|
||||
}
|
||||
|
||||
@ -1688,7 +1688,7 @@ class Sql
|
||||
$goto,
|
||||
$sqlQuery
|
||||
);
|
||||
$displayResultsObject->setConfigParamsForDisplayTable();
|
||||
$displayResultsObject->setConfigParamsForDisplayTable($analyzedSqlResults);
|
||||
|
||||
// assign default full_sql_query
|
||||
$fullSqlQuery = $sqlQuery;
|
||||
|
||||
@ -1129,6 +1129,28 @@ class ResultsTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testPftextConfigParam(): void
|
||||
{
|
||||
$db = 'test_db';
|
||||
$table = 'test_table';
|
||||
|
||||
$query = 'ANALYZE FORMAT=JSON SELECT * FROM test_table';
|
||||
[$analyzedSqlResults] = ParseAnalyze::sqlQuery($query, $db);
|
||||
|
||||
$object = new DisplayResults($this->dbi, $db, $table, 1, '', $query);
|
||||
$object->setConfigParamsForDisplayTable($analyzedSqlResults);
|
||||
|
||||
$this->assertSame('F', $_SESSION['tmpval']['pftext']);
|
||||
|
||||
$query = 'ANALYZE NO_WRITE_TO_BINLOG TABLE test_table';
|
||||
[$analyzedSqlResults] = ParseAnalyze::sqlQuery($query, $db);
|
||||
|
||||
$object = new DisplayResults($this->dbi, $db, $table, 1, '', $query);
|
||||
$object->setConfigParamsForDisplayTable($analyzedSqlResults);
|
||||
|
||||
$this->assertSame('P', $_SESSION['tmpval']['pftext']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerSetConfigParamsForDisplayTable
|
||||
*/
|
||||
@ -1147,9 +1169,10 @@ class ResultsTest extends AbstractTestCase
|
||||
$db = 'test_db';
|
||||
$table = 'test_table';
|
||||
$query = 'SELECT * FROM `test_db`.`test_table`;';
|
||||
[$analyzedSqlResults] = ParseAnalyze::sqlQuery($query, $db);
|
||||
|
||||
$object = new DisplayResults($this->dbi, $db, $table, 1, '', $query);
|
||||
$object->setConfigParamsForDisplayTable();
|
||||
$object->setConfigParamsForDisplayTable($analyzedSqlResults);
|
||||
|
||||
$this->assertArrayHasKey('tmpval', $_SESSION);
|
||||
$this->assertIsArray($_SESSION['tmpval']);
|
||||
@ -1162,7 +1185,7 @@ class ResultsTest extends AbstractTestCase
|
||||
|
||||
return [
|
||||
'default values' => [
|
||||
[],
|
||||
[' PMA_token ' => 'token'],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
@ -1216,6 +1239,7 @@ class ResultsTest extends AbstractTestCase
|
||||
'j' => [],
|
||||
],
|
||||
],
|
||||
' PMA_token ' => 'token',
|
||||
],
|
||||
[],
|
||||
[],
|
||||
@ -1254,7 +1278,7 @@ class ResultsTest extends AbstractTestCase
|
||||
],
|
||||
],
|
||||
'default and request values' => [
|
||||
[],
|
||||
[' PMA_token ' => 'token',],
|
||||
['session_max_rows' => '27'],
|
||||
['session_max_rows' => '28'],
|
||||
[
|
||||
@ -1317,6 +1341,7 @@ class ResultsTest extends AbstractTestCase
|
||||
'i' => [],
|
||||
],
|
||||
],
|
||||
' PMA_token ' => 'token',
|
||||
],
|
||||
[],
|
||||
['session_max_rows' => DisplayResults::ALL_ROWS],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user