Skip to content

Commit f291fcc

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2 parents 737354c + ca3c713 commit f291fcc

8 files changed

Lines changed: 93 additions & 17 deletions

File tree

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14394,12 +14394,6 @@ parameters:
1439414394
count: 2
1439514395
path: src/Utils/HttpRequest.php
1439614396

14397-
-
14398-
message: '#^Used function http_get_last_response_headers not found\.$#'
14399-
identifier: function.notFound
14400-
count: 1
14401-
path: src/Utils/HttpRequest.php
14402-
1440314397
-
1440414398
message: '''
1440514399
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:

resources/templates/database/data_dictionary/index.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<div>
1414
<h2>{{ table.name }}</h2>
1515
{% if table.comment is not empty %}
16-
<p>{{ t('Table comments:') }} <em>{{ table.comment }}</em></p>
16+
{{ t('Table comments:') }}
17+
<em><pre>{{ table.comment }}</pre></em>
1718
{% endif %}
1819

1920
<table class="table table-striped align-middle">

resources/templates/table/structure/display_table_stats.twig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
<div class="card-header">{{ t('Information') }}</div>
33
<div class="card-body">
44
{% if showtable['TABLE_COMMENT'] %}
5-
<p>
6-
<strong>{{ t('Table comments:') }}</strong>
7-
{{ showtable['TABLE_COMMENT'] }}
8-
</p>
5+
<strong>{{ t('Table comments:') }}</strong>
6+
<em><pre>{{ showtable['TABLE_COMMENT'] }}</pre></em>
97
{% endif %}
108
<a id="showusage"></a>
119

src/Display/Results.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,11 +2970,12 @@ public function getTable(
29702970

29712971
[$displayParts, $total] = $this->setDisplayPartsAndTotal($displayParts);
29722972

2973+
$hasParserError = $statementInfo->parser->errors !== [];
29732974
// 1.2 Defines offsets for the next and previous pages
29742975
$posNext = 0;
29752976
$posPrev = 0;
29762977
if ($displayParts->hasNavigationBar) {
2977-
[$posNext, $posPrev] = $this->getOffsets();
2978+
[$posNext, $posPrev] = $hasParserError ? [$total, 0] : $this->getOffsets();
29782979
}
29792980

29802981
// 1.3 Extract sorting expressions.
@@ -3052,7 +3053,12 @@ public function getTable(
30523053
}
30533054

30543055
$navigation = [];
3055-
if ($displayParts->hasNavigationBar && $statement !== null && empty($statement->limit)) {
3056+
if (
3057+
$displayParts->hasNavigationBar &&
3058+
! $hasParserError &&
3059+
$statement !== null &&
3060+
empty($statement->limit)
3061+
) {
30563062
$navigation = $this->getTableNavigation($posNext, $posPrev, $sortByKeyData);
30573063
}
30583064

src/Query/Compatibility.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,43 @@ public static function isVirtualColumnsSupported(int $serverVersion): bool
155155
return false;
156156
}
157157

158+
/**
159+
* Check whether the database supports JSON data type
160+
*
161+
* @return bool true if JSON is supported
162+
*/
163+
public static function isJsonSupported(DatabaseInterface $dbi): bool
164+
{
165+
// @see: https://mariadb.com/kb/en/mariadb-1027-release-notes/#json
166+
// @see: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-8.html#mysqld-5-7-8-json
167+
return $dbi->isMariaDB() && $dbi->getVersion() >= 100207 || // 10.2.7
168+
! $dbi->isMariaDB() && $dbi->getVersion() >= 50708; // 5.7.8
169+
}
170+
158171
/**
159172
* Check whether the database supports UUID data type
160-
* true if uuid is supported
173+
*
174+
* @return bool true if UUID is supported
161175
*/
162176
public static function isUUIDSupported(DatabaseInterface $dbi): bool
163177
{
164178
// @see: https://mariadb.com/kb/en/mariadb-1070-release-notes/#uuid
165179
return $dbi->isMariaDB() && $dbi->getVersion() >= 100700; // 10.7.0
166180
}
167181

182+
/**
183+
* Check whether the database supports VECTOR data type
184+
*
185+
* @return bool true if VECTOR is supported
186+
*/
187+
public static function isVectorSupported(DatabaseInterface $dbi): bool
188+
{
189+
// @see: https://mariadb.com/docs/release-notes/community-server/old-releases/mariadb-11-7-rolling-releases/mariadb-11-7-1-release-notes#vectors
190+
// @see: https://dev.mysql.com/doc/relnotes/mysql/9.0/en/news-9-0-0.html#mysqld-9-0-0-vectors
191+
return $dbi->isMariaDB() && $dbi->getVersion() >= 110701 || // 11.7.1
192+
$dbi->isMySql() && $dbi->getVersion() >= 90000; // 9.0.0
193+
}
194+
168195
/**
169196
* Returns whether the database server supports virtual columns
170197
*/

src/Types.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,9 @@ public function getColumns(): array
587587
{
588588
$isMariaDB = $this->dbi->isMariaDB();
589589
$serverVersion = $this->dbi->getVersion();
590+
$isJsonSupported = Compatibility::isJsonSupported($this->dbi);
590591
$isUUIDSupported = Compatibility::isUUIDSupported($this->dbi);
592+
$isVectorSupported = Compatibility::isVectorSupported($this->dbi);
591593

592594
// most used types
593595
$ret = ['INT', 'VARCHAR', 'TEXT', 'DATE'];
@@ -656,14 +658,18 @@ public function getColumns(): array
656658
'GEOMETRYCOLLECTION',
657659
];
658660

659-
if (($isMariaDB && $serverVersion > 100207) || (! $isMariaDB && $serverVersion >= 50708)) {
661+
if ($isJsonSupported) {
660662
$ret['JSON'] = ['JSON'];
661663
}
662664

663665
if ($isUUIDSupported) {
664666
$ret['UUID'] = ['UUID'];
665667
}
666668

669+
if ($isVectorSupported) {
670+
$ret['VECTOR'] = ['VECTOR'];
671+
}
672+
667673
return $ret;
668674
}
669675

src/Utils/HttpRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use function file_get_contents;
1717
use function function_exists;
1818
use function getenv;
19-
use function http_get_last_response_headers;
2019
use function ini_get;
2120
use function is_array;
2221
use function is_dir;
@@ -238,7 +237,8 @@ private function fopen(
238237
);
239238

240239
if (function_exists('http_get_last_response_headers')) {
241-
$http_response_header = http_get_last_response_headers();
240+
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
241+
$http_response_header = \http_get_last_response_headers();
242242
}
243243

244244
if (! isset($http_response_header)) {

tests/unit/Query/CompatibilityTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ public function testIsUUIDSupported(bool $expected, bool $isMariaDb, int $versio
4646
self::assertSame($expected, Compatibility::isUUIDSupported($dbiStub));
4747
}
4848

49+
/** @return array<string, array{bool, bool, int}> */
50+
public static function providerForTestIsVectorSupported(): array
51+
{
52+
return [
53+
'MySQL 8.99.99' => [false, false, 89999],
54+
'MySQL 9.0.0' => [false, false, 90000],
55+
'MariaDB 11.6.99' => [false, true, 110699],
56+
'MariaDB 11.7.1' => [true, true, 110701],
57+
];
58+
}
59+
60+
#[DataProvider('providerForTestIsVectorSupported')]
61+
public function testIsVectorSupported(bool $expected, bool $isMariaDb, int $version): void
62+
{
63+
$dbiStub = self::createStub(DatabaseInterface::class);
64+
65+
$dbiStub->method('isMariaDB')->willReturn($isMariaDb);
66+
$dbiStub->method('getVersion')->willReturn($version);
67+
68+
self::assertSame($expected, Compatibility::isVectorSupported($dbiStub));
69+
}
70+
4971
/**
5072
* @return mixed[][]
5173
* @psalm-return array<string, array{bool, bool, int}>
@@ -60,6 +82,28 @@ public static function providerForTestIsUUIDSupported(): array
6082
];
6183
}
6284

85+
#[DataProvider('providerForTestIsJsonSupported')]
86+
public function testIsJsonSupported(bool $expected, bool $isMariaDb, int $version): void
87+
{
88+
$dbiStub = self::createStub(DatabaseInterface::class);
89+
90+
$dbiStub->method('isMariaDB')->willReturn($isMariaDb);
91+
$dbiStub->method('getVersion')->willReturn($version);
92+
93+
self::assertSame($expected, Compatibility::isJsonSupported($dbiStub));
94+
}
95+
96+
/** @return array<string, array{bool, bool, int}> */
97+
public static function providerForTestIsJsonSupported(): array
98+
{
99+
return [
100+
'MySQL 5.7.7' => [false, false, 50707],
101+
'MySQL 5.7.8' => [false, true, 50708],
102+
'MariaDB 10.2.6' => [false, true, 100206],
103+
'MariaDB 10.2.7' => [true, true, 100207],
104+
];
105+
}
106+
63107
#[DataProvider('showBinLogStatusProvider')]
64108
public function testGetShowBinLogStatusStmt(string $serverName, int $version, string $expected): void
65109
{

0 commit comments

Comments
 (0)