Skip to content

Commit 059705f

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents 4cd6b23 + 72a6045 commit 059705f

18 files changed

Lines changed: 64 additions & 118 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"require-dev": {
9898
"bacon/bacon-qr-code": "^2.0",
9999
"code-lts/u2f-php-server": "^1.2",
100-
"php-webdriver/webdriver": "^1.11",
100+
"php-webdriver/webdriver": "^1.13",
101101
"phpmyadmin/coding-standard": "^3.0.0",
102102
"phpstan/extension-installer": "^1.1",
103103
"phpstan/phpstan": "^1.8",

‎libraries/classes/Controllers/Import/ImportController.php‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use function is_array;
3636
use function is_link;
3737
use function is_numeric;
38+
use function is_string;
3839
use function is_uploaded_file;
3940
use function mb_strlen;
4041
use function mb_strtolower;
@@ -448,7 +449,13 @@ public function __invoke(ServerRequest $request): void
448449
$GLOBALS['read_limit'] = $GLOBALS['memory_limit'] / 8;
449450

450451
// handle filenames
451-
if (isset($_FILES['import_file'])) {
452+
if (
453+
isset($_FILES['import_file'])
454+
&& is_array($_FILES['import_file'])
455+
&& isset($_FILES['import_file']['name'], $_FILES['import_file']['tmp_name'])
456+
&& is_string($_FILES['import_file']['name'])
457+
&& is_string($_FILES['import_file']['tmp_name'])
458+
) {
452459
$GLOBALS['import_file'] = $_FILES['import_file']['tmp_name'];
453460
$GLOBALS['import_file_name'] = $_FILES['import_file']['name'];
454461
}
@@ -630,7 +637,12 @@ public function __invoke(ServerRequest $request): void
630637

631638
if (! empty($GLOBALS['local_import_file'])) {
632639
$GLOBALS['message']->addText('(' . $GLOBALS['local_import_file'] . ')');
633-
} else {
640+
} elseif (
641+
isset($_FILES['import_file'])
642+
&& is_array($_FILES['import_file'])
643+
&& isset($_FILES['import_file']['name'])
644+
&& is_string($_FILES['import_file']['name'])
645+
) {
634646
$GLOBALS['message']->addText('(' . $_FILES['import_file']['name'] . ')');
635647
}
636648
}

‎libraries/classes/Controllers/Preferences/ManageController.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use function define;
2525
use function file_exists;
2626
use function is_array;
27+
use function is_string;
2728
use function is_uploaded_file;
2829
use function json_decode;
2930
use function json_encode;
@@ -126,7 +127,10 @@ public function __invoke(ServerRequest $request): void
126127
if (
127128
isset($_POST['import_type'], $_FILES['import_file'])
128129
&& $_POST['import_type'] === 'text_file'
130+
&& is_array($_FILES['import_file'])
129131
&& $_FILES['import_file']['error'] == UPLOAD_ERR_OK
132+
&& isset($_FILES['import_file']['tmp_name'])
133+
&& is_string($_FILES['import_file']['tmp_name'])
130134
&& is_uploaded_file($_FILES['import_file']['tmp_name'])
131135
) {
132136
$importHandle = new File($_FILES['import_file']['tmp_name']);

‎libraries/classes/Display/Results.php‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,16 +2461,7 @@ private function getRowValues(
24612461

24622462
$displayParams = $this->properties['display_params'] ?? [];
24632463

2464-
// in some situations (issue 11406), numeric returns 1
2465-
// even for a string type
2466-
// for decimal numeric is returning 1
2467-
// have to improve logic
2468-
// Nullable text fields and text fields have the blob flag (issue 16896)
2469-
$isNumericAndNotBlob = $meta->isNumeric && ! $meta->isBlob;
2470-
if (
2471-
($isNumericAndNotBlob && $meta->isNotType(FieldMetadata::TYPE_STRING))
2472-
|| $meta->isType(FieldMetadata::TYPE_REAL)
2473-
) {
2464+
if ($meta->isNumeric) {
24742465
// n u m e r i c
24752466

24762467
$displayParams['data'][$rowNumber][$i] = $this->getDataCellForNumericColumns(

‎libraries/classes/Export.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
use function time;
4949
use function trim;
5050

51+
use const ENT_COMPAT;
52+
5153
/**
5254
* PhpMyAdmin\Export class
5355
*/
@@ -211,7 +213,7 @@ public function outputHandler(?string $line): bool
211213
}
212214
} else {
213215
// We export as html - replace special chars
214-
echo htmlspecialchars((string) $line);
216+
echo htmlspecialchars((string) $line, ENT_COMPAT);
215217
}
216218

217219
return true;

‎libraries/classes/FieldMetadata.php‎

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use const MYSQLI_ENUM_FLAG;
1313
use const MYSQLI_MULTIPLE_KEY_FLAG;
1414
use const MYSQLI_NOT_NULL_FLAG;
15-
use const MYSQLI_NUM_FLAG;
1615
use const MYSQLI_PRI_KEY_FLAG;
1716
use const MYSQLI_SET_FLAG;
1817
use const MYSQLI_TYPE_BIT;
@@ -229,29 +228,26 @@ public function __construct(int $fieldType, int $fieldFlags, object $field)
229228
{
230229
$this->mappedType = $this->getTypeMap()[$fieldType] ?? null;
231230

232-
$this->isMultipleKey = (bool) ($fieldFlags & MYSQLI_MULTIPLE_KEY_FLAG);
233-
$this->isPrimaryKey = (bool) ($fieldFlags & MYSQLI_PRI_KEY_FLAG);
234-
$this->isUniqueKey = (bool) ($fieldFlags & MYSQLI_UNIQUE_KEY_FLAG);
235-
$this->isNotNull = (bool) ($fieldFlags & MYSQLI_NOT_NULL_FLAG);
236-
$this->isUnsigned = (bool) ($fieldFlags & MYSQLI_UNSIGNED_FLAG);
237-
$this->isZerofill = (bool) ($fieldFlags & MYSQLI_ZEROFILL_FLAG);
238-
239-
// as flags 32768 can be NUM_FLAG or GROUP_FLAG
240-
// reference: https://www.php.net/manual/en/mysqli-result.fetch-fields.php
241-
// so check field type instead of flags
242-
// but if no or unknown field type then check flags
243-
$this->isNumeric = $this->isType(self::TYPE_INT)
244-
|| ($fieldType <= 0 && ($fieldFlags & MYSQLI_NUM_FLAG));
245-
246-
$this->isBlob = (bool) ($fieldFlags & MYSQLI_BLOB_FLAG);
247-
$this->isEnum = (bool) ($fieldFlags & MYSQLI_ENUM_FLAG);
248-
$this->isSet = (bool) ($fieldFlags & MYSQLI_SET_FLAG);
249-
250-
/*
251-
MYSQLI_PART_KEY_FLAG => 'part_key',
252-
MYSQLI_TIMESTAMP_FLAG => 'timestamp',
253-
MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
254-
*/
231+
$this->isMultipleKey = (bool) ($fieldFlags & MYSQLI_MULTIPLE_KEY_FLAG);
232+
$this->isPrimaryKey = (bool) ($fieldFlags & MYSQLI_PRI_KEY_FLAG);
233+
$this->isUniqueKey = (bool) ($fieldFlags & MYSQLI_UNIQUE_KEY_FLAG);
234+
$this->isNotNull = (bool) ($fieldFlags & MYSQLI_NOT_NULL_FLAG);
235+
$this->isUnsigned = (bool) ($fieldFlags & MYSQLI_UNSIGNED_FLAG);
236+
$this->isZerofill = (bool) ($fieldFlags & MYSQLI_ZEROFILL_FLAG);
237+
$this->isBlob = (bool) ($fieldFlags & MYSQLI_BLOB_FLAG);
238+
$this->isEnum = (bool) ($fieldFlags & MYSQLI_ENUM_FLAG);
239+
$this->isSet = (bool) ($fieldFlags & MYSQLI_SET_FLAG);
240+
241+
// as flags 32768 can be NUM_FLAG or GROUP_FLAG
242+
// reference: https://www.php.net/manual/en/mysqli-result.fetch-fields.php
243+
// so check field type instead of flags
244+
$this->isNumeric = $this->isType(self::TYPE_INT) || $this->isType(self::TYPE_REAL);
245+
246+
/*
247+
MYSQLI_PART_KEY_FLAG => 'part_key',
248+
MYSQLI_TIMESTAMP_FLAG => 'timestamp',
249+
MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
250+
*/
255251

256252
$this->isMappedTypeBit = $this->isType(self::TYPE_BIT);
257253
$this->isMappedTypeGeometry = $this->isType(self::TYPE_GEOMETRY);
@@ -377,14 +373,6 @@ public function isSet(): bool
377373
return $this->isSet;
378374
}
379375

380-
/**
381-
* Checks that it is type INT or type REAL
382-
*/
383-
public function isNumericType(): bool
384-
{
385-
return $this->isType(self::TYPE_INT) || $this->isType(self::TYPE_REAL);
386-
}
387-
388376
/**
389377
* Checks that it is type DATE/TIME/DATETIME
390378
*/

‎libraries/classes/Html/Generator.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public static function linkToVarDocumentation(
9393
$kbs = ServerVariablesProvider::getImplementation();
9494
$link = $useMariaDB ? $kbs->getDocLinkByNameMariaDb($name) :
9595
$kbs->getDocLinkByNameMysql($name);
96+
$link = $link !== null ? Core::linkURL($link) : $link;
9697

9798
return MySQLDocumentation::show($name, false, $link, $text);
9899
}

‎libraries/classes/Plugins/Export/ExportOds.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,7 @@ public function exportData(
282282
. '</text:p>'
283283
. '</table:table-cell>';
284284
} elseif (
285-
($fieldsMeta[$j]->isNumeric
286-
&& ! $fieldsMeta[$j]->isMappedTypeTimestamp
287-
&& ! $fieldsMeta[$j]->isBlob)
288-
|| $fieldsMeta[$j]->isType(FieldMetadata::TYPE_REAL)
285+
$fieldsMeta[$j]->isNumeric
289286
) {
290287
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float"'
291288
. ' office:value="' . $row[$j] . '" >'

‎libraries/classes/Plugins/Export/ExportOdt.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ public function exportData(
294294
. '</table:table-cell>';
295295
} elseif (
296296
$fieldsMeta[$j]->isNumeric
297-
&& ! $fieldsMeta[$j]->isMappedTypeTimestamp
298-
&& ! $fieldsMeta[$j]->isBlob
299297
) {
300298
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="float"'
301299
. ' office:value="' . $row[$j] . '" >'

‎libraries/classes/Plugins/Export/ExportSql.php‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,12 +2331,8 @@ public function exportData(
23312331
$values[] = 'NULL';
23322332
} elseif (
23332333
$metaInfo->isNumeric
2334-
&& ! $metaInfo->isMappedTypeTimestamp
2335-
&& ! $metaInfo->isBlob
23362334
) {
23372335
// a number
2338-
// timestamp is numeric on some MySQL 4.1, BLOBs are
2339-
// sometimes numeric
23402336
$values[] = $row[$j];
23412337
} elseif ($metaInfo->isBinary && isset($GLOBALS['sql_hex_for_binary'])) {
23422338
// a true BLOB

0 commit comments

Comments
 (0)