Merge pull request #18434 from kamil-tekiela/InsertEdit-pt-3

InsertEdit refactoring - part 3
This commit is contained in:
Maurício Meneghini Fauth 2023-05-23 11:02:09 -03:00 committed by GitHub
commit 30ff7d4b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 361 additions and 419 deletions

View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin;
final class ColumnFull
{
public function __construct(
public readonly string $field,
public readonly string $type,
public readonly string|null $collation,
public readonly bool $isNull,
public readonly string $key,
public readonly string|null $default,
public readonly string $extra,
public readonly string $privileges,
public readonly string $comment,
) {
}
}

View File

@ -531,7 +531,7 @@ class Relation
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
*
* @return mixed[] [column_name] = comment
* @return string[] [column_name] = comment
*/
public function getComments(string $db, string $table = ''): array
{
@ -544,7 +544,7 @@ class Relation
// MySQL native column comments
$columns = $this->dbi->getColumns($db, $table, true);
foreach ($columns as $column) {
if (empty($column['Comment'])) {
if ($column['Comment'] === '') {
continue;
}

View File

@ -84,7 +84,7 @@ class DataDictionaryController extends AbstractController
'has_primary_key' => isset($primaryKeys[$row['Field']]),
'type' => $extractedColumnSpec['type'],
'print_type' => $extractedColumnSpec['print_type'],
'is_nullable' => $row['Null'] !== '' && $row['Null'] !== 'NO',
'is_nullable' => $row['Null'] !== 'NO',
'default' => $row['Default'] ?? null,
'comment' => $columnsComments[$row['Field']] ?? '',
'mime' => $mime,

View File

@ -163,8 +163,8 @@ class ChangeController extends AbstractController
$GLOBALS['urlParams'] = $this->urlParamsInEditMode($GLOBALS['urlParams'], $whereClauseArray);
$hasBlobField = false;
foreach ($tableColumns as $column) {
if ($this->insertEdit->isColumn($column, ['blob', 'tinyblob', 'mediumblob', 'longblob'])) {
foreach ($tableColumns as $tableColumn) {
if ($this->insertEdit->isColumn($tableColumn->type, ['blob', 'tinyblob', 'mediumblob', 'longblob'])) {
$hasBlobField = true;
break;
}

View File

@ -91,7 +91,7 @@ class FindReplaceController extends AbstractController
// set column name
$this->columnNames[] = $row['Field'];
$type = (string) $row['Type'];
$type = $row['Type'];
// reformat mysql query output
if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) {
$type = str_replace(',', ', ', $type);

View File

@ -109,7 +109,7 @@ class SearchController extends AbstractController
// set column name
$this->columnNames[] = $row['Field'];
$type = (string) $row['Type'];
$type = $row['Type'];
// before any replacement
$this->originalColumnTypes[] = mb_strtolower($type);
// check whether table contains geometric columns

View File

@ -61,7 +61,7 @@ final class ChangeController extends AbstractController
$fieldsMeta = [];
foreach ($selected as $column) {
$value = $this->dbi->getColumn($GLOBALS['db'], $GLOBALS['table'], $column, true);
if ($value === []) {
if ($value === null) {
$message = Message::error(
__('Failed to get description of column %s!'),
);

View File

@ -165,7 +165,7 @@ class ZoomSearchController extends AbstractController
// set column name
$this->columnNames[] = $row['Field'];
$type = (string) $row['Type'];
$type = $row['Type'];
// before any replacement
$this->originalColumnTypes[] = mb_strtolower($type);
// check whether table contains geometric columns

View File

@ -293,7 +293,7 @@ class CentralColumns
$hasList = $this->findExistingColNames($db, trim($cols, ','));
foreach ($fieldSelect as $table) {
foreach ($fields[$table] as $def) {
$field = (string) $def['Field'];
$field = $def['Field'];
if (! in_array($field, $hasList)) {
$hasList[] = $field;
$insQuery[] = $this->getInsertQuery($field, $def, $db, $centralListTable);

View File

@ -839,7 +839,17 @@ class DatabaseInterface implements DbalInterface
* @param bool $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] flat array description
* @return array{
* Field: string,
* Type: string,
* Collation?: string|null,
* Null:'YES'|'NO',
* Key: string,
* Default: string|null,
* Extra: string,
* Privileges?: string,
* Comment?: string
* }|null
*/
public function getColumn(
string $database,
@ -847,19 +857,19 @@ class DatabaseInterface implements DbalInterface
string $column,
bool $full = false,
int $connectionType = Connection::TYPE_USER,
): array {
): array|null {
$sql = QueryGenerator::getColumnsSql(
$database,
$table,
$this->escapeString($this->escapeMysqlWildcards($column)),
$full,
);
/** @var array<string, array> $fields */
/** @var (string|null)[][] $fields */
$fields = $this->fetchResult($sql, 'Field', null, $connectionType);
$columns = $this->attachIndexInfoToColumns($database, $table, $fields);
return array_shift($columns) ?? [];
return array_shift($columns);
}
/**
@ -870,7 +880,17 @@ class DatabaseInterface implements DbalInterface
* @param bool $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @return mixed[][] array indexed by column names
* @return array{
* Field: string,
* Type: string,
* Collation?: string|null,
* Null:'YES'|'NO',
* Key: string,
* Default: string|null,
* Extra: string,
* Privileges?: string,
* Comment?: string
* }[] array indexed by column names
*/
public function getColumns(
string $database,
@ -879,7 +899,7 @@ class DatabaseInterface implements DbalInterface
int $connectionType = Connection::TYPE_USER,
): array {
$sql = QueryGenerator::getColumnsSql($database, $table, null, $full);
/** @var array[] $fields */
/** @var (string|null)[][] $fields */
$fields = $this->fetchResult($sql, 'Field', null, $connectionType);
return $this->attachIndexInfoToColumns($database, $table, $fields);
@ -888,11 +908,11 @@ class DatabaseInterface implements DbalInterface
/**
* Attach index information to the column definition
*
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @param mixed[][] $fields column array indexed by their names
* @param string $database name of database
* @param string $table name of table to retrieve columns from
* @param (string|null)[][] $fields column array indexed by their names
*
* @return mixed[][] Column defintions with index information
* @return (string|null)[][] Column defintions with index information
*/
private function attachIndexInfoToColumns(
string $database,

View File

@ -173,7 +173,17 @@ interface DbalInterface
* @param bool $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @return mixed[] flat array description
* @return array{
* Field: string,
* Type: string,
* Collation?: string|null,
* Null:'YES'|'NO',
* Key: string,
* Default: string|null,
* Extra: string,
* Privileges?: string,
* Comment?: string
* }|null
*/
public function getColumn(
string $database,
@ -181,7 +191,7 @@ interface DbalInterface
string $column,
bool $full = false,
int $connectionType = Connection::TYPE_USER,
): array;
): array|null;
/**
* Returns descriptions of columns in given table
@ -191,7 +201,17 @@ interface DbalInterface
* @param bool $full whether to return full info or only column names
* @psalm-param ConnectionType $connectionType
*
* @return mixed[][] array indexed by column names
* @return array{
* Field: string,
* Type: string,
* Collation?: string|null,
* Null:'YES'|'NO',
* Key: string,
* Default: string|null,
* Extra: string,
* Privileges?: string,
* Comment?: string
* }[] array indexed by column names
*/
public function getColumns(
string $database,

View File

@ -15,7 +15,6 @@ use function __;
use function array_fill;
use function array_key_exists;
use function array_merge;
use function array_values;
use function bin2hex;
use function class_exists;
use function count;
@ -46,7 +45,6 @@ use function stripcslashes;
use function stripslashes;
use function strlen;
use function substr;
use function time;
use function trim;
use const ENT_COMPAT;
@ -304,36 +302,57 @@ class InsertEdit
/**
* Analyze the table column array
*
* @param mixed[] $column description of column in given table
* @param mixed[] $commentsMap comments for every column that has a comment
* @param ColumnFull $tableColumn description of column in given table
* @param string[] $commentsMap comments for every column that has a comment
* @param int $columnLength length of the current column taken from field metadata
* @param bool $insertMode whether insert mode
*
* @return mixed[] description of column in given table
*/
private function analyzeTableColumnsArray(
array $column,
ColumnFull $tableColumn,
array $commentsMap,
int $columnLength,
bool $insertMode,
): array {
$column['Field_md5'] = md5($column['Field']);
$column = [
'Field' => $tableColumn->field,
'Type' => $tableColumn->type,
'Collation' => $tableColumn->collation,
'Null' => $tableColumn->isNull ? 'YES' : 'NO',
'Key' => $tableColumn->key,
'Default' => $tableColumn->default,
'Extra' => $tableColumn->extra,
'Privileges' => $tableColumn->privileges,
'Comment' => $tableColumn->comment,
];
$column['Field_md5'] = md5($tableColumn->field);
// True_Type contains only the type (stops at first bracket)
$column['True_Type'] = preg_replace('@\(.*@s', '', $column['Type']);
$column['len'] = preg_match('@float|double@', $column['Type']) ? 100 : -1;
$column['Field_title'] = $this->getColumnTitle($column, $commentsMap);
$column['True_Type'] = preg_replace('@\(.*@s', '', $tableColumn->type);
$column['len'] = preg_match('@float|double@', $tableColumn->type) ? 100 : $columnLength;
// length is unknown for geometry fields,
// make enough space to edit very simple WKTs
if ($column['len'] === -1) {
$column['len'] = 30;
}
$column['Field_title'] = $this->getColumnTitle($tableColumn->field, $commentsMap);
$column['is_binary'] = $this->isColumn(
$column,
$tableColumn->type,
['binary', 'varbinary'],
);
$column['is_blob'] = $this->isColumn(
$column,
$tableColumn->type,
['blob', 'tinyblob', 'mediumblob', 'longblob'],
);
$column['is_char'] = $this->isColumn(
$column,
$tableColumn->type,
['char', 'varchar'],
);
$column['pma_type'] = match ($column['True_Type']) {
'set', 'enum' => $column['True_Type'],
default => $column['Type']
default => $tableColumn->type,
};
$column['wrap'] = match ($column['True_Type']) {
@ -344,26 +363,35 @@ class InsertEdit
// can only occur once per table
$column['first_timestamp'] = $column['True_Type'] === 'timestamp';
if (
$tableColumn->type === 'datetime'
&& ! $tableColumn->isNull
&& $tableColumn->default === null
&& $insertMode
) {
$column['Default'] = date('Y-m-d H:i:s');
}
return $column;
}
/**
* Retrieve the column title
*
* @param mixed[] $column description of column in given table
* @param mixed[] $commentsMap comments for every column that has a comment
* @param string $fieldName name of the column
* @param string[] $commentsMap comments for every column that has a comment
*
* @return string column title
*/
private function getColumnTitle(array $column, array $commentsMap): string
private function getColumnTitle(string $fieldName, array $commentsMap): string
{
if (isset($commentsMap[$column['Field']])) {
if (isset($commentsMap[$fieldName])) {
return '<span style="border-bottom: 1px dashed black;" title="'
. htmlspecialchars($commentsMap[$column['Field']]) . '">'
. htmlspecialchars($column['Field']) . '</span>';
. htmlspecialchars($commentsMap[$fieldName]) . '">'
. htmlspecialchars($fieldName) . '</span>';
}
return htmlspecialchars($column['Field']);
return htmlspecialchars($fieldName);
}
/**
@ -371,13 +399,13 @@ class InsertEdit
* the goal is to ensure that types such as "enum('one','two','binary',..)"
* or "enum('one','two','varbinary',..)" are not categorized as binary
*
* @param mixed[] $column description of column in given table
* @param string[] $types the types to verify
* @param string $columnType column type as specified in the column definition
* @param string[] $types the types to verify
*/
public function isColumn(array $column, array $types): bool
public function isColumn(string $columnType, array $types): bool
{
foreach ($types as $oneType) {
if (mb_stripos($column['Type'], $oneType) === 0) {
if (mb_stripos($columnType, $oneType) === 0) {
return true;
}
}
@ -1503,13 +1531,28 @@ class InsertEdit
* @param string $db current db
* @param string $table current table
*
* @return mixed[][]
* @return list<ColumnFull>
*/
public function getTableColumns(string $db, string $table): array
{
$this->dbi->selectDb($db);
return array_values($this->dbi->getColumns($db, $table, true));
$columns = [];
foreach ($this->dbi->getColumns($db, $table, true) as $column) {
$columns[] = new ColumnFull(
$column['Field'],
$column['Type'],
$column['Collation'],
$column['Null'] === 'YES',
$column['Key'],
$column['Default'],
$column['Extra'],
$column['Privileges'],
$column['Comment'],
);
}
return $columns;
}
/**
@ -1600,7 +1643,7 @@ class InsertEdit
* @param string $db current database
* @param string $table current table
*
* @return mixed[] comments for columns
* @return string[] comments for columns
*/
public function getCommentsMap(string $db, string $table): array
{
@ -1655,29 +1698,29 @@ class InsertEdit
/**
* Function to get html for each insert/edit column
*
* @param mixed[] $column column
* @param int $columnNumber column index in table_columns
* @param mixed[] $commentsMap comments map
* @param ResultInterface $currentResult current result
* @param bool $insertMode whether insert mode
* @param mixed[] $currentRow current row
* @param int $columnsCnt columns count
* @param bool $isUpload whether upload
* @param mixed[] $foreigners foreigners
* @param string $table table
* @param string $db database
* @param int $rowId row id
* @param string $defaultCharEditing default char editing mode which is stored in the config.inc.php script
* @param string $textDir text direction
* @param mixed[] $repopulate the data to be repopulated
* @param mixed[] $columnMime the mime information of column
* @param string $whereClause the where clause
* @param ColumnFull $tableColumn column
* @param int $columnNumber column index in table_columns
* @param string[] $commentsMap comments map
* @param int $columnLength length of the current column taken from field metadata
* @param bool $insertMode whether insert mode
* @param mixed[] $currentRow current row
* @param int $columnsCnt columns count
* @param bool $isUpload whether upload
* @param mixed[] $foreigners foreigners
* @param string $table table
* @param string $db database
* @param int $rowId row id
* @param string $defaultCharEditing default char editing mode which is stored in the config.inc.php script
* @param string $textDir text direction
* @param mixed[] $repopulate the data to be repopulated
* @param mixed[] $columnMime the mime information of column
* @param string $whereClause the where clause
*/
private function getHtmlForInsertEditFormColumn(
array $column,
ColumnFull $tableColumn,
int $columnNumber,
array $commentsMap,
ResultInterface $currentResult,
int $columnLength,
bool $insertMode,
array $currentRow,
int $columnsCnt,
@ -1692,9 +1735,7 @@ class InsertEdit
array $columnMime,
string $whereClause,
): string {
if (! isset($column['processed'])) {
$column = $this->analyzeTableColumnsArray($column, $commentsMap);
}
$column = $this->analyzeTableColumnsArray($tableColumn, $commentsMap, $columnLength, $insertMode);
$asIs = false;
/** @var string $fieldHashMd5 */
@ -1706,15 +1747,6 @@ class InsertEdit
$extractedColumnspec = Util::extractColumnSpec($column['Type']);
if ($column['len'] === -1) {
$column['len'] = $this->dbi->getFieldsMeta($currentResult)[$columnNumber]->length;
// length is unknown for geometry fields,
// make enough space to edit very simple WKTs
if ($column['len'] === -1) {
$column['len'] = 30;
}
}
//Call validation when the form submitted...
$onChangeClause = 'return verificationsAfterFieldChange('
. json_encode($fieldHashMd5) . ', '
@ -1725,10 +1757,6 @@ class InsertEdit
// in the name attribute (see bug #1746964 )
$columnNameAppendix = $vkey . '[' . $fieldHashMd5 . ']';
if ($column['Type'] === 'datetime' && $column['Null'] !== 'YES' && ! isset($column['Default']) && $insertMode) {
$column['Default'] = date('Y-m-d H:i:s', time());
}
// Get a list of GIS data types.
$gisDataTypes = Gis::getDataTypes();
@ -1998,20 +2026,20 @@ class InsertEdit
/**
* Function to get html for each insert/edit row
*
* @param mixed[] $urlParams url parameters
* @param mixed[][] $tableColumns table columns
* @param mixed[] $commentsMap comments map
* @param ResultInterface $currentResult current result
* @param bool $insertMode whether insert mode
* @param mixed[] $currentRow current row
* @param bool $isUpload whether upload
* @param mixed[] $foreigners foreigners
* @param string $table table
* @param string $db database
* @param int $rowId row id
* @param string $textDir text direction
* @param mixed[] $repopulate the data to be repopulated
* @param mixed[] $whereClauseArray the array of where clauses
* @param mixed[] $urlParams url parameters
* @param list<ColumnFull> $tableColumns table columns
* @param string[] $commentsMap comments map
* @param ResultInterface $currentResult current result
* @param bool $insertMode whether insert mode
* @param mixed[] $currentRow current row
* @param bool $isUpload whether upload
* @param mixed[] $foreigners foreigners
* @param string $table table
* @param string $db database
* @param int $rowId row id
* @param string $textDir text direction
* @param mixed[] $repopulate the data to be repopulated
* @param mixed[] $whereClauseArray the array of where clauses
*/
public function getHtmlForInsertEditRow(
array $urlParams,
@ -2044,12 +2072,12 @@ class InsertEdit
for ($columnNumber = 0; $columnNumber < $columnCount; $columnNumber++) {
$tableColumn = $tableColumns[$columnNumber];
$columnMime = [];
if (isset($mimeMap[$tableColumn['Field']])) {
$columnMime = $mimeMap[$tableColumn['Field']];
if (isset($mimeMap[$tableColumn->field])) {
$columnMime = $mimeMap[$tableColumn->field];
}
$virtual = ['VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED'];
if (in_array($tableColumn['Extra'], $virtual)) {
if (in_array($tableColumn->extra, $virtual)) {
continue;
}
@ -2057,7 +2085,7 @@ class InsertEdit
$tableColumn,
$columnNumber,
$commentsMap,
$currentResult,
$this->dbi->getFieldsMeta($currentResult)[$columnNumber]->length,
$insertMode,
$currentRow,
$columnCount,

View File

@ -72,7 +72,7 @@ class Normalization
$type = '';
$selectColHtml = '';
foreach ($columns as $def) {
$column = (string) $def['Field'];
$column = $def['Field'];
if (isset($def['Type'])) {
$extractedColumnSpec = Util::extractColumnSpec($def['Type']);
$type = $extractedColumnSpec['type'];

View File

@ -574,8 +574,7 @@ class ExportLatex extends ExportPlugin
}
$localBuffer = $colAs . "\000" . $type . "\000"
. ($row['Null'] == '' || $row['Null'] === 'NO'
? __('No') : __('Yes'))
. ($row['Null'] === 'NO' ? __('No') : __('Yes'))
. "\000" . ($row['Default'] ?? '');
if ($doRelation && $haveRel) {

View File

@ -568,7 +568,7 @@ class Pdf extends PdfLib
$data[] = $column['Field'];
$data[] = $type;
$data[] = $column['Null'] == '' || $column['Null'] === 'NO'
$data[] = $column['Null'] === 'NO'
? 'No'
: 'Yes';
$data[] = $column['Default'] ?? '';

View File

@ -680,7 +680,7 @@ class PdfRelationSchema extends ExportRelationSchema
$type = $extractedColumnSpec['print_type'];
$attribute = $extractedColumnSpec['attribute'];
if (! isset($row['Default'])) {
if ($row['Null'] != '' && $row['Null'] !== 'NO') {
if ($row['Null'] !== 'NO') {
$row['Default'] = 'NULL';
}
}
@ -712,7 +712,7 @@ class PdfRelationSchema extends ExportRelationSchema
$fieldName,
$type,
$attribute,
$row['Null'] == '' || $row['Null'] === 'NO'
$row['Null'] === 'NO'
? __('No')
: __('Yes'),
$row['Default'] ?? '',

View File

@ -685,6 +685,11 @@ parameters:
count: 1
path: libraries/classes/ConfigStorage/Relation.php
-
message: "#^Offset 'Comment' does not exist on array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\}\\.$#"
count: 1
path: libraries/classes/ConfigStorage/Relation.php
-
message: "#^Parameter \\#1 \\$foreigners of method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:searchColumnInForeigners\\(\\) expects array, array\\|true given\\.$#"
count: 1
@ -771,7 +776,7 @@ parameters:
path: libraries/classes/Controllers/Database/CentralColumnsController.php
-
message: "#^Cannot access offset mixed on mixed\\.$#"
message: "#^Cannot access offset string on mixed\\.$#"
count: 1
path: libraries/classes/Controllers/Database/DataDictionaryController.php
@ -780,16 +785,6 @@ parameters:
count: 1
path: libraries/classes/Controllers/Database/DataDictionaryController.php
-
message: "#^Parameter \\#1 \\$columnSpecification of static method PhpMyAdmin\\\\Util\\:\\:extractColumnSpec\\(\\) expects string, mixed given\\.$#"
count: 1
path: libraries/classes/Controllers/Database/DataDictionaryController.php
-
message: "#^Parameter \\#2 \\$column of method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:searchColumnInForeigners\\(\\) expects string, mixed given\\.$#"
count: 1
path: libraries/classes/Controllers/Database/DataDictionaryController.php
-
message: "#^Cannot access offset 'dbName' on mixed\\.$#"
count: 2
@ -2090,11 +2085,6 @@ parameters:
count: 2
path: libraries/classes/Controllers/Table/FindReplaceController.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: libraries/classes/Controllers/Table/FindReplaceController.php
-
message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#"
count: 16
@ -2165,16 +2155,6 @@ parameters:
count: 1
path: libraries/classes/Controllers/Table/RelationController.php
-
message: "#^Parameter \\#1 \\$string of function md5 expects string, mixed given\\.$#"
count: 1
path: libraries/classes/Controllers/Table/RelationController.php
-
message: "#^Parameter \\#2 \\$callback of function uksort expects callable\\(int\\|string, int\\|string\\)\\: int, 'strnatcasecmp' given\\.$#"
count: 1
path: libraries/classes/Controllers/Table/RelationController.php
-
message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, 'strnatcasecmp' given\\.$#"
count: 1
@ -2217,7 +2197,7 @@ parameters:
-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
count: 1
path: libraries/classes/Controllers/Table/SearchController.php
-
@ -2522,7 +2502,7 @@ parameters:
-
message: "#^Cannot cast mixed to string\\.$#"
count: 3
count: 2
path: libraries/classes/Controllers/Table/ZoomSearchController.php
-
@ -2737,7 +2717,7 @@ parameters:
-
message: "#^Cannot cast mixed to string\\.$#"
count: 4
count: 3
path: libraries/classes/Database/CentralColumns.php
-
@ -2777,7 +2757,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:escapeString\\(\\) expects string, mixed given\\.$#"
count: 6
count: 5
path: libraries/classes/Database/CentralColumns.php
-
@ -2800,6 +2780,11 @@ parameters:
count: 1
path: libraries/classes/Database/CentralColumns.php
-
message: "#^Parameter \\#2 \\$def of method PhpMyAdmin\\\\Database\\\\CentralColumns\\:\\:getInsertQuery\\(\\) expects array, array\\<string, string\\|null\\>\\|null given\\.$#"
count: 1
path: libraries/classes/Database/CentralColumns.php
-
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
count: 1
@ -3140,11 +3125,6 @@ parameters:
count: 1
path: libraries/classes/Database/Routines.php
-
message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#"
count: 1
path: libraries/classes/Database/Search.php
-
message: "#^Property PhpMyAdmin\\\\Database\\\\Search\\:\\:\\$searchTypeDescription \\(string\\) does not accept mixed\\.$#"
count: 1
@ -3320,11 +3300,21 @@ parameters:
count: 1
path: libraries/classes/DatabaseInterface.php
-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumn\\(\\) should return array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\}\\|null but returns array\\<string\\|null\\>\\|null\\.$#"
count: 1
path: libraries/classes/DatabaseInterface.php
-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumnNames\\(\\) should return array\\<string\\> but returns array\\.$#"
count: 1
path: libraries/classes/DatabaseInterface.php
-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumns\\(\\) should return array\\<array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\}\\> but returns array\\<array\\<string\\|null\\>\\>\\.$#"
count: 1
path: libraries/classes/DatabaseInterface.php
-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumnsFull\\(\\) should return array but returns mixed\\.$#"
count: 1
@ -3345,11 +3335,6 @@ parameters:
count: 1
path: libraries/classes/DatabaseInterface.php
-
message: "#^PHPDoc tag @var for variable \\$fields has no value type specified in iterable type array\\.$#"
count: 2
path: libraries/classes/DatabaseInterface.php
-
message: "#^Parameter \\#1 \\$a of static method PhpMyAdmin\\\\Query\\\\Utilities\\:\\:usortComparisonCallback\\(\\) expects array, mixed given\\.$#"
count: 1
@ -4572,7 +4557,7 @@ parameters:
-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
count: 3
path: libraries/classes/InsertEdit.php
-
@ -4585,18 +4570,38 @@ parameters:
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Offset 'Collation' does not exist on array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\}\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Offset 'Comment' does not exist on array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\}\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Offset 'Privileges' does not exist on array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\}\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$buffer of method PhpMyAdmin\\\\Plugins\\\\TransformationsPlugin\\:\\:applyTransformation\\(\\) expects string, mixed given\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$columnSpecification of static method PhpMyAdmin\\\\Util\\:\\:extractColumnSpec\\(\\) expects string, mixed given\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$data of static method PhpMyAdmin\\\\Utils\\\\Gis\\:\\:convertToWellKnownText\\(\\) expects string, mixed given\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$haystack of function mb_stripos expects string, mixed given\\.$#"
message: "#^Parameter \\#1 \\$defaultValue of method PhpMyAdmin\\\\InsertEdit\\:\\:getSpecialCharsForInsertingMode\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
@ -4635,16 +4640,6 @@ parameters:
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$string of function htmlspecialchars expects string, mixed given\\.$#"
count: 3
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$string of function md5 expects string, mixed given\\.$#"
count: 1
path: libraries/classes/InsertEdit.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#"
count: 1
@ -4930,11 +4925,6 @@ parameters:
count: 2
path: libraries/classes/Normalization.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: libraries/classes/Normalization.php
-
message: "#^Casting to string something that's already string\\.$#"
count: 1
@ -4956,12 +4946,12 @@ parameters:
path: libraries/classes/Normalization.php
-
message: "#^Parameter \\#1 \\$array of function array_unique expects array, mixed given\\.$#"
message: "#^Offset 'Type' on array\\{Field\\: string, Type\\: string, Collation\\?\\: string\\|null, Null\\: 'NO'\\|'YES', Key\\: string, Default\\: string\\|null, Extra\\: string, Privileges\\?\\: string, \\.\\.\\.\\} in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: libraries/classes/Normalization.php
-
message: "#^Parameter \\#1 \\$columnSpecification of static method PhpMyAdmin\\\\Util\\:\\:extractColumnSpec\\(\\) expects string, mixed given\\.$#"
message: "#^Parameter \\#1 \\$array of function array_unique expects array, mixed given\\.$#"
count: 1
path: libraries/classes/Normalization.php
@ -5322,7 +5312,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$string of function htmlspecialchars expects string, mixed given\\.$#"
count: 8
count: 7
path: libraries/classes/Plugins/Export/ExportHtmlword.php
-
@ -5462,7 +5452,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$string of function htmlspecialchars expects string, mixed given\\.$#"
count: 9
count: 8
path: libraries/classes/Plugins/Export/ExportOdt.php
-
@ -5707,7 +5697,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$string of function htmlspecialchars expects string, mixed given\\.$#"
count: 5
count: 4
path: libraries/classes/Plugins/Export/ExportTexytext.php
-
@ -7865,11 +7855,6 @@ parameters:
count: 1
path: libraries/classes/Sql.php
-
message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, mixed given\\.$#"
count: 1
path: libraries/classes/Sql.php
-
message: "#^Parameter \\#1 \\$message of static method PhpMyAdmin\\\\Message\\:\\:rawError\\(\\) expects string, mixed given\\.$#"
count: 1
@ -9060,11 +9045,6 @@ parameters:
count: 2
path: test/classes/Controllers/Table/ReplaceControllerTest.php
-
message: "#^Cannot cast mixed to string\\.$#"
count: 3
path: test/classes/Controllers/Table/StructureControllerTest.php
-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\<string\\> will always evaluate to true\\.$#"
count: 1

View File

@ -744,7 +744,6 @@
<code><![CDATA[$_SESSION['tmpval']['recentTables'][$GLOBALS['server']]]]></code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$comments[$column['Field']]]]></code>
<code>$foreign[$field]</code>
<code>$foreign[$field]</code>
<code>$foreign[$key]</code>
@ -754,7 +753,6 @@
<code>$childReferences</code>
<code>$column</code>
<code>$columns</code>
<code><![CDATA[$comments[$column['Field']]]]></code>
<code>$field</code>
<code>$foreignDb</code>
<code>$foreignField</code>
@ -803,6 +801,10 @@
<PossiblyInvalidArgument>
<code>$foreigners</code>
</PossiblyInvalidArgument>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$column['Comment']]]></code>
<code><![CDATA[$column['Comment']]]></code>
</PossiblyUndefinedArrayOffset>
<PossiblyUnusedMethod>
<code>getDbComments</code>
</PossiblyUnusedMethod>
@ -959,17 +961,6 @@
</RedundantCast>
</file>
<file src="libraries/classes/Controllers/Database/DataDictionaryController.php">
<MixedArgument>
<code><![CDATA[$row['Field']]]></code>
<code><![CDATA[$row['Type']]]></code>
</MixedArgument>
<MixedArrayOffset>
<code><![CDATA[$columnsComments[$row['Field']]]]></code>
<code><![CDATA[$mimeMap[$row['Field']]]]></code>
<code><![CDATA[$mimeMap[$row['Field']]]]></code>
<code><![CDATA[$primaryKeys[$row['Field']]]]></code>
<code><![CDATA[$rows[$row['Field']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$relation</code>
</MixedAssignment>
@ -3650,7 +3641,6 @@
<code><![CDATA[usort($tables, 'strnatcasecmp')]]></code>
</InvalidArgument>
<MixedArgument>
<code><![CDATA[$column['Field']]]></code>
<code>$foreignDb</code>
<code>$foreignTable</code>
<code>$html</code>
@ -3660,20 +3650,14 @@
: []]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[uksort($columnArray, 'strnatcasecmp')]]></code>
<code><![CDATA[usort($columnList, 'strnatcasecmp')]]></code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$oneKey['ref_db_name']]]></code>
<code><![CDATA[$oneKey['ref_table_name']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$columnArray[$column['Field']]]]></code>
<code><![CDATA[$columnHashArray[$column['Field']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['display_query']]]></code>
<code><![CDATA[$columnArray[$column['Field']]]]></code>
<code>$existrelForeign</code>
<code>$foreignDb</code>
<code>$foreignTable</code>
@ -4181,7 +4165,6 @@
<code>$attributes[$rownum]</code>
<code>$columnsList[]</code>
<code>$field</code>
<code>$rowComments[$rownum]</code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$GLOBALS['showtable']['Data_length']]]></code>
@ -4754,7 +4737,6 @@
<code><![CDATA[$def['Type']]]></code>
<code>$default</code>
<code><![CDATA[$extractedColumnSpec['attribute']]]></code>
<code>$field</code>
<code>$key</code>
<code><![CDATA[$meta['DefaultValue']]]></code>
<code><![CDATA[$meta['DefaultValue']]]></code>
@ -4846,7 +4828,6 @@
<code>$defaultValue</code>
<code>$defaultValues[$rowNum]</code>
<code>$extra</code>
<code>$field</code>
<code>$hasList[]</code>
<code>$key</code>
<code>$length</code>
@ -4901,6 +4882,9 @@
<code>$db</code>
<code>$table</code>
</PossiblyInvalidCast>
<PossiblyNullArgument>
<code>$field</code>
</PossiblyNullArgument>
<RedundantCast>
<code><![CDATA[(bool) $GLOBALS['cfg']['Server']['DisableIS']]]></code>
<code><![CDATA[(int) $GLOBALS['cfg']['MaxRows']]]></code>
@ -5526,9 +5510,6 @@
<InvalidPropertyAssignmentValue>
<code><![CDATA[array_intersect($_POST['criteriaTables'], $this->tablesNamesOnly)]]></code>
</InvalidPropertyAssignmentValue>
<MixedArgument>
<code><![CDATA[$column['Field']]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$this->searchTypeDescription]]></code>
</MixedAssignment>
@ -5759,6 +5740,7 @@
<code>reset($columns)</code>
</MixedReturnStatement>
<MixedReturnTypeCoercion>
<code><![CDATA[$this->attachIndexInfoToColumns($database, $table, $fields)]]></code>
<code><![CDATA[$this->fetchResult($sql, null, 'Field', $connectionType)]]></code>
<code><![CDATA[$this->fetchResult($sql, null, null, $connectionType)]]></code>
<code><![CDATA[array<int, array{
@ -5779,6 +5761,29 @@
* Visible?: string,
* Expression?: string|null
* }>]]></code>
<code>array_shift($columns)</code>
<code><![CDATA[array{
* Field: string,
* Type: string,
* Collation?: string|null,
* Null:'YES'|'NO',
* Key: string,
* Default: string|null,
* Extra: string,
* Privileges?: string,
* Comment?: string
* }[]]]></code>
<code><![CDATA[array{
* Field: string,
* Type: string,
* Collation?: string|null,
* Null:'YES'|'NO',
* Key: string,
* Default: string|null,
* Extra: string,
* Privileges?: string,
* Comment?: string
* }|null]]></code>
<code>string[]</code>
</MixedReturnTypeCoercion>
<NullableReturnStatement>
@ -7606,9 +7611,6 @@
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$column['Field']]]></code>
<code><![CDATA[$column['Field']]]></code>
<code><![CDATA[$column['Field']]]></code>
<code><![CDATA[$column['Field']]]></code>
<code><![CDATA[$column['Field']]]></code>
<code><![CDATA[$column['True_Type']]]></code>
<code><![CDATA[$column['True_Type']]]></code>
<code><![CDATA[$column['True_Type']]]></code>
@ -7619,15 +7621,11 @@
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$column['pma_type']]]></code>
<code><![CDATA[$column['pma_type']]]></code>
<code><![CDATA[$column['pma_type']]]></code>
<code><![CDATA[$column['pma_type']]]></code>
<code><![CDATA[$column['pma_type']]]></code>
<code><![CDATA[$commentsMap[$column['Field']]]]></code>
<code>$currCellEditedValues[$columnName]</code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
@ -7674,8 +7672,6 @@
<code><![CDATA[$extraData['transformations'][$cellIndex]]]></code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$commentsMap[$column['Field']]]]></code>
<code><![CDATA[$commentsMap[$column['Field']]]]></code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
@ -7698,12 +7694,9 @@
<code><![CDATA[$currentRow[$column['Field']]]]></code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
<code><![CDATA[$mimeMap[$tableColumn['Field']]]]></code>
<code><![CDATA[$mimeMap[$tableColumn['Field']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$columnSetValues</code>
<code><![CDATA[$column['pma_type']]]></code>
<code><![CDATA[$column['values']]]></code>
<code>$currCellEditedValues</code>
<code><![CDATA[$currentRow[$column['Field']]]]></code>
@ -7775,6 +7768,9 @@
<code><![CDATA[$_POST['where_clause'][0]]]></code>
</PossiblyInvalidOperand>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$column['Collation']]]></code>
<code><![CDATA[$column['Comment']]]></code>
<code><![CDATA[$column['Privileges']]]></code>
<code><![CDATA[$column['is_blob']]]></code>
</PossiblyUndefinedArrayOffset>
<RedundantCast>
@ -8230,9 +8226,6 @@
<code>$col</code>
<code><![CDATA[$cols['nonpk']]]></code>
<code><![CDATA[$cols['pk']]]></code>
<code><![CDATA[$def['Type']]]></code>
<code><![CDATA[$def['Type']]]></code>
<code><![CDATA[$def['Type']]]></code>
<code>$dependent</code>
<code>$dependents</code>
<code>$dependents</code>
@ -8297,10 +8290,6 @@
<code><![CDATA[$def['Type']]]></code>
<code><![CDATA[$def['Type']]]></code>
</PossiblyNullArgument>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$def['Type']]]></code>
<code><![CDATA[$def['Type']]]></code>
</PossiblyUndefinedArrayOffset>
<RedundantCast>
<code>(string) $dependon</code>
</RedundantCast>
@ -8922,7 +8911,6 @@
<code><![CDATA[$column['Type']]]></code>
<code>$comments[$fieldName]</code>
<code><![CDATA[$extractedColumnSpec['print_type']]]></code>
<code>$fieldName</code>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
<code><![CDATA[$trigger['action_timing']]]></code>
<code><![CDATA[$trigger['definition']]]></code>
@ -8938,21 +8926,12 @@
<code><![CDATA[$trigger['event_manipulation']]]></code>
<code><![CDATA[$trigger['name']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$aliases[$db]['tables'][$table]['columns'][$colAs]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$view]['columns'][$colAs]]]></code>
<code>$comments[$fieldName]</code>
<code>$mimeMap[$fieldName]</code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['what']]]></code>
<code>$colAlias</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$fieldName</code>
<code>$trigger</code>
<code>$value</code>
</MixedAssignment>
@ -9001,29 +8980,21 @@
<MixedArgument>
<code>$columnsAlias[$i]</code>
<code>$escape[$k]</code>
<code>$fieldName</code>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
<code><![CDATA[$row['Type']]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$aliases[$db]['tables'][$table]['columns'][$colAs]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$columnsAlias[$i]</code>
<code>$fieldName</code>
<code>$type</code>
</MixedAssignment>
<MixedOperand>
<code>$colAs</code>
<code>$comments[$fieldName]</code>
<code>$escape[$k]</code>
<code><![CDATA[$row['Default'] ?? '']]></code>
<code>$type</code>
</MixedOperand>
<ParamNameMismatch>
@ -9059,21 +9030,13 @@
<code><![CDATA[$GLOBALS['mediawiki_headers']]]></code>
<code><![CDATA[$GLOBALS['mediawiki_headers']]]></code>
</InvalidArrayOffset>
<MixedArrayOffset>
<code><![CDATA[$aliases[$db]['tables'][$table]['columns'][$colAs]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$colAs</code>
<code>$colAs</code>
<code>$column</code>
</MixedAssignment>
<MixedOperand>
<code>$colAs</code>
<code>$column</code>
<code><![CDATA[$columns[$i]['Default']]]></code>
<code><![CDATA[$columns[$i]['Extra']]]></code>
<code><![CDATA[$columns[$i]['Null']]]></code>
<code><![CDATA[$columns[$i]['Type']]]></code>
</MixedOperand>
<ParamNameMismatch>
<code>$doComments</code>
@ -9081,6 +9044,7 @@
<code>$doRelation</code>
</ParamNameMismatch>
<PossiblyNullOperand>
<code><![CDATA[$columns[$i]['Default']]]></code>
<code>$row[$i]</code>
<code>$tableAlias</code>
<code>$tableAlias</code>
@ -9127,7 +9091,6 @@
<code><![CDATA[$column['Type']]]></code>
<code>$comments[$fieldName]</code>
<code><![CDATA[$extractedColumnSpec['print_type']]]></code>
<code>$fieldName</code>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
<code><![CDATA[$trigger['action_timing']]]></code>
<code><![CDATA[$trigger['definition']]]></code>
@ -9145,8 +9108,6 @@
<code><![CDATA[$aliases[$db]['tables'][$rtable]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$rtable]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$rtable]['columns'][$rfield]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$table]['columns'][$colAs]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$view]['columns'][$colAs]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['what']]]></code>
@ -9154,9 +9115,6 @@
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$fieldName</code>
<code>$rfield</code>
<code>$rfield</code>
<code>$rtable</code>
@ -9280,9 +9238,6 @@
<code>$colAlias</code>
<code>$colAlias</code>
<code>$colAs</code>
<code><![CDATA[$column['Comment']]]></code>
<code><![CDATA[$column['Default']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code>$engine</code>
<code>$eventName</code>
<code>$eventName</code>
@ -9318,7 +9273,6 @@
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$aliases[$db]['tables'][$table]['columns'][$field]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$view]['columns'][$colAlias]]]></code>
<code><![CDATA[$oneKey['ref_index_list'][$index]]]></code>
</MixedArrayOffset>
<MixedArrayTypeCoercion>
@ -9331,7 +9285,6 @@
<code><![CDATA[$GLOBALS['sql_indexes_query']]]></code>
<code>$colAlias</code>
<code>$colAlias</code>
<code>$colAlias</code>
<code>$colAs</code>
<code>$columnAliases</code>
<code>$definition</code>
@ -9353,8 +9306,6 @@
<code>$trigger</code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$column['Collation']]]></code>
<code><![CDATA[$column['Type']]]></code>
<code><![CDATA[$definition['Type']]]></code>
<code><![CDATA[$statement->entityOptions->has('AUTO_INCREMENT')]]></code>
<code><![CDATA[$trigger['drop']]]></code>
@ -9436,7 +9387,6 @@
<code><![CDATA[$column['Default'] ?? '']]></code>
<code><![CDATA[$column['Type']]]></code>
<code>$comments[$fieldName]</code>
<code>$fieldName</code>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
<code><![CDATA[$trigger['definition']]]></code>
<code>$type</code>
@ -9451,21 +9401,12 @@
<code><![CDATA[$trigger['event_manipulation']]]></code>
<code><![CDATA[$trigger['name']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$aliases[$db]['tables'][$table]['columns'][$colAs]]]></code>
<code><![CDATA[$aliases[$db]['tables'][$view]['columns'][$colAs]]]></code>
<code>$comments[$fieldName]</code>
<code>$mimeMap[$fieldName]</code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['what']]]></code>
<code>$colAlias</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$colAs</code>
<code>$fieldName</code>
<code>$trigger</code>
<code>$type</code>
<code>$value</code>
@ -9575,7 +9516,6 @@
<code><![CDATA[$GLOBALS['maxY'] - $this->tMargin]]></code>
<code>$cellFontSize</code>
<code>$colAs</code>
<code><![CDATA[$column['Type']]]></code>
<code>$fullwidth + $l</code>
<code>$fullwidth + $l</code>
<code>$fullwidth + $l</code>
@ -9674,10 +9614,6 @@
<code><![CDATA[$trigger['name']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code>$comments[$fieldName]</code>
<code>$mimeMap[$fieldName]</code>
<code>$resRel[$fieldName]</code>
<code>$resRel[$fieldName]</code>
<code><![CDATA[$this->headerset[$this->page]]]></code>
<code><![CDATA[$this->headerset[$this->page]]]></code>
<code><![CDATA[$this->pagedim[$oldpage]]]></code>
@ -9705,9 +9641,6 @@
<code>$data[]</code>
<code>$data[]</code>
<code>$data[]</code>
<code>$data[]</code>
<code>$data[]</code>
<code>$fieldName</code>
<code>$fullwidth</code>
<code>$fullwidth</code>
<code>$fullwidth</code>
@ -10744,15 +10677,12 @@
<code><![CDATA[$this->diagram->PageNo()]]></code>
</InvalidArgument>
<MixedArgument>
<code>$fieldName</code>
<code>$fieldName</code>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
<code>$oneField</code>
<code><![CDATA[$oneKey['ref_index_list'][$index]]]></code>
<code><![CDATA[$oneKey['ref_table_name']]]></code>
<code><![CDATA[$rel['foreign_field']]]></code>
<code><![CDATA[$rel['foreign_table']]]></code>
<code><![CDATA[$row['Type']]]></code>
<code><![CDATA[$showTable['Check_time']]]></code>
<code><![CDATA[$showTable['Create_time']]]></code>
<code><![CDATA[$showTable['Update_time']]]></code>
@ -10804,19 +10734,14 @@
<code><![CDATA[$foreignTable[$foreigner['foreign_field']]]]></code>
<code><![CDATA[$oneKey['ref_index_list'][$index]]]></code>
<code><![CDATA[$this->diagram->customLinks['RT'][$table]]]></code>
<code><![CDATA[$this->diagram->customLinks['RT'][$table][$fieldName]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$foreigner['foreign_table']]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$foreigner['foreign_table']]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$table]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$table]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$table][$fieldName]]]></code>
<code><![CDATA[$this->diagram->customLinks['doc'][$table][$fieldName]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$attribute</code>
<code>$fieldName</code>
<code>$fieldName</code>
<code>$foreignTable</code>
<code>$index</code>
<code>$links[0]</code>
@ -10848,9 +10773,6 @@
<code><![CDATA[$_REQUEST['pdf_paper']]]></code>
<code><![CDATA[$_REQUEST['pdf_table_order']]]></code>
</PossiblyInvalidCast>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$row['Null']]]></code>
</PossiblyUndefinedArrayOffset>
<PossiblyUnusedMethod>
<code>isWithDataDictionary</code>
</PossiblyUnusedMethod>
@ -11571,8 +11493,6 @@
<code>$errorMessage</code>
<code>$serverReplicationVariable</code>
<code>$successMessage</code>
<code><![CDATA[$val['Type']]]></code>
<code><![CDATA[$val['Type']]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$GLOBALS['urlParams']]]></code>
@ -12309,7 +12229,6 @@
<code><![CDATA[$GLOBALS['show_as_php']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$columns[$indexColumnName]['Extra']]]></code>
<code><![CDATA[$extraData['error']]]></code>
<code><![CDATA[$fieldInfoResult[0]['Type']]]></code>
<code><![CDATA[$foreignData['foreign_field']]]></code>
@ -13355,7 +13274,6 @@
<MixedAssignment>
<code>$array</code>
<code>$columnNames[]</code>
<code>$columnNames[]</code>
<code><![CDATA[$indexesData[$row['Key_name']][$row['Seq_in_index']]['Column_name']]]></code>
<code><![CDATA[$indexesData[$row['Key_name']][$row['Seq_in_index']]['Sub_part']]]></code>
<code><![CDATA[$indexesInfo[$row['Key_name']]['Cardinality']]]></code>

View File

@ -117,9 +117,9 @@ class StructureControllerTest extends AbstractTestCase
'table_stats' => null,
'fields' => $fields,
'extracted_columnspecs' => [
1 => Util::extractColumnSpec((string) $fields['id']['Type']),
2 => Util::extractColumnSpec((string) $fields['name']['Type']),
3 => Util::extractColumnSpec((string) $fields['datetimefield']['Type']),
1 => Util::extractColumnSpec($fields['id']['Type']),
2 => Util::extractColumnSpec($fields['name']['Type']),
3 => Util::extractColumnSpec($fields['datetimefield']['Type']),
],
'columns_with_index' => [],
'central_list' => [],

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\ColumnFull;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
@ -413,13 +414,13 @@ class InsertEditTest extends AbstractTestCase
*/
public function testAnalyzeTableColumnsArray(): void
{
$column = ['Field' => '1<2', 'Field_md5' => 'pswd', 'Type' => 'float(10, 1)'];
$column = new ColumnFull('1<2', 'float(10, 1)', null, false, '', null, '', '', '');
$result = $this->callFunction(
$this->insertEdit,
InsertEdit::class,
'analyzeTableColumnsArray',
[$column, []],
[$column, [], -1, false],
);
$this->assertEquals($result['Field_md5'], '4342210df36bf2ff2c4e2a997a6d4089');
@ -448,15 +449,14 @@ class InsertEditTest extends AbstractTestCase
*/
public function testGetColumnTitle(): void
{
$column = [];
$column['Field'] = 'f1<';
$fieldName = 'f1<';
$this->assertEquals(
$this->callFunction(
$this->insertEdit,
InsertEdit::class,
'getColumnTitle',
[$column, []],
[$fieldName, []],
),
'f1&lt;',
);
@ -468,7 +468,7 @@ class InsertEditTest extends AbstractTestCase
$this->insertEdit,
InsertEdit::class,
'getColumnTitle',
[$column, $comments],
[$fieldName, $comments],
);
$result = $this->parseString($result);
@ -483,51 +483,50 @@ class InsertEditTest extends AbstractTestCase
*/
public function testIsColumn(): void
{
$column = [];
$types = ['binary', 'varbinary'];
$column['Type'] = 'binaryfoo';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'binaryfoo';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'Binaryfoo';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'Binaryfoo';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'varbinaryfoo';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'varbinaryfoo';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'barbinaryfoo';
$this->assertFalse($this->insertEdit->isColumn($column, $types));
$columnType = 'barbinaryfoo';
$this->assertFalse($this->insertEdit->isColumn($columnType, $types));
$types = ['char', 'varchar'];
$column['Type'] = 'char(10)';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'char(10)';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'VarChar(20)';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'VarChar(20)';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'foochar';
$this->assertFalse($this->insertEdit->isColumn($column, $types));
$columnType = 'foochar';
$this->assertFalse($this->insertEdit->isColumn($columnType, $types));
$types = ['blob', 'tinyblob', 'mediumblob', 'longblob'];
$column['Type'] = 'blob';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'blob';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'bloB';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'bloB';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'mediumBloB';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'mediumBloB';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'tinyblobabc';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'tinyblobabc';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'longblob';
$this->assertTrue($this->insertEdit->isColumn($column, $types));
$columnType = 'longblob';
$this->assertTrue($this->insertEdit->isColumn($columnType, $types));
$column['Type'] = 'foolongblobbar';
$this->assertFalse($this->insertEdit->isColumn($column, $types));
$columnType = 'foolongblobbar';
$this->assertFalse($this->insertEdit->isColumn($columnType, $types));
}
/**
@ -2218,7 +2217,30 @@ class InsertEditTest extends AbstractTestCase
$dbi->expects($this->once())
->method('getColumns')
->with('db', 'table')
->will($this->returnValue([['a' => 'b', 'c' => 'd'], ['e' => 'f', 'g' => 'h']]));
->will($this->returnValue([
[
'Field' => 'b',
'Type' => 'd',
'Collation' => null,
'Null' => 'NO',
'Key' => '',
'Default' => null,
'Extra' => '',
'Privileges' => '',
'Comment' => '',
],
[
'Field' => 'f',
'Type' => 'h',
'Collation' => null,
'Null' => 'YES',
'Key' => '',
'Default' => null,
'Extra' => '',
'Privileges' => '',
'Comment' => '',
],
]));
$GLOBALS['dbi'] = $dbi;
$this->insertEdit = new InsertEdit(
@ -2232,7 +2254,10 @@ class InsertEditTest extends AbstractTestCase
$result = $this->insertEdit->getTableColumns('db', 'table');
$this->assertEquals(
[['a' => 'b', 'c' => 'd'], ['e' => 'f', 'g' => 'h']],
[
new ColumnFull('b', 'd', null, false, '', null, '', '', ''),
new ColumnFull('f', 'h', null, true, '', null, '', '', ''),
],
$result,
);
}
@ -2379,23 +2404,13 @@ class InsertEditTest extends AbstractTestCase
$_SESSION[' HMAC_secret '] = hash('sha1', 'test');
$GLOBALS['plugin_scripts'] = [];
$foreigners = ['foreign_keys_data' => []];
$tableColumn = [
'Field' => 'col',
'Type' => 'varchar(20)',
'Null' => 'Yes',
'Privileges' => 'insert,update,select',
];
$tableColumn = new ColumnFull('col', 'varchar(20)', null, true, '', null, '', 'insert,update,select', '');
$repopulate = [md5('col') => 'val'];
$columnMime = [
'input_transformation' => 'Input/Image_JPEG_Upload.php',
'input_transformation_options' => '150',
];
$resultStub = $this->createMock(DummyResult::class);
$resultStub->expects($this->any())
->method('getFieldsMeta')
->will($this->returnValue([FieldHelper::fromArray(['type' => 0, 'length' => -1])]));
// Test w/ input transformation
$actual = $this->callFunction(
$this->insertEdit,
@ -2405,7 +2420,7 @@ class InsertEditTest extends AbstractTestCase
$tableColumn,
0,
[],
$resultStub,
-1,
false,
[],
0,
@ -2440,15 +2455,7 @@ class InsertEditTest extends AbstractTestCase
);
// Test w/o input_transformation
$tableColumn = [
'Field' => 'qwerty',
'Type' => 'datetime',
'Null' => 'Yes',
'Key' => '',
'Extra' => '',
'Default' => null,
'Privileges' => 'insert,update,select',
];
$tableColumn = new ColumnFull('qwerty', 'datetime', null, true, '', null, '', 'insert,update,select', '');
$repopulate = [md5('qwerty') => '12-10-14'];
$actual = $this->callFunction(
$this->insertEdit,
@ -2458,7 +2465,7 @@ class InsertEditTest extends AbstractTestCase
$tableColumn,
0,
[],
$resultStub,
-1,
true,
[],
0,
@ -2537,15 +2544,7 @@ class InsertEditTest extends AbstractTestCase
$GLOBALS['cfg']['TextareaCols'] = 11;
$foreigners = ['foreign_keys_data' => []];
$tableColumns = [
[
'Field' => 'test',
'Extra' => '',
'Type' => 'longtext',
'Null' => 'Yes',
'pma_type' => 'longtext',
'True_Type' => 'longtext',
'Privileges' => 'select,insert,update,references',
],
new ColumnFull('test', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
];
$resultStub = $this->createMock(DummyResult::class);
@ -2593,24 +2592,8 @@ class InsertEditTest extends AbstractTestCase
// edit
$tableColumns = [
[
'Field' => 'foo',
'Type' => 'longtext',
'Extra' => '',
'Null' => 'Yes',
'pma_type' => 'longtext',
'True_Type' => 'longtext',
'Privileges' => 'select,insert,update,references',
],
[
'Field' => 'bar',
'Type' => 'longtext',
'Extra' => '',
'Null' => 'Yes',
'pma_type' => 'longtext',
'True_Type' => 'longtext',
'Privileges' => 'select,insert,references',
],
new ColumnFull('foo', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
new ColumnFull('bar', 'longtext', null, true, '', null, '', 'select,insert,references', ''),
];
$resultStub = $this->createMock(DummyResult::class);
@ -2643,36 +2626,9 @@ class InsertEditTest extends AbstractTestCase
// insert
$tableColumns = [
[
'Field' => 'foo',
'Type' => 'longtext',
'Extra' => '',
'Null' => 'Yes',
'Key' => '',
'pma_type' => 'longtext',
'True_Type' => 'longtext',
'Privileges' => 'select,insert,update,references',
],
[
'Field' => 'bar',
'Type' => 'longtext',
'Extra' => '',
'Null' => 'Yes',
'Key' => '',
'pma_type' => 'longtext',
'True_Type' => 'longtext',
'Privileges' => 'select,update,references',
],
[
'Field' => 'point',
'Type' => 'point',
'Extra' => '',
'Null' => 'No',
'Key' => '',
'pma_type' => 'point',
'True_Type' => 'point',
'Privileges' => 'select,update,references',
],
new ColumnFull('foo', 'longtext', null, true, '', null, '', 'select,insert,update,references', ''),
new ColumnFull('bar', 'longtext', null, true, '', null, '', 'select,update,references', ''),
new ColumnFull('point', 'point', null, false, '', null, '', 'select,update,references', ''),
];
$actual = $this->insertEdit->getHtmlForInsertEditRow(
[],

View File

@ -1643,11 +1643,11 @@ class DbiDummy implements DbiExtension
],
[
'query' => 'SHOW FULL COLUMNS FROM `test_db`.`test_table`',
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
'result' => [
['id', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
['name', 'varchar(20)', 'NO', '', 'NULL', ''],
['datetimefield', 'datetime', 'NO', '', 'NULL', ''],
['id', 'int(11)', null, 'NO', 'PRI', 'NULL', 'auto_increment', '', ''],
['name', 'varchar(20)', null, 'NO', '', 'NULL', '', '', ''],
['datetimefield', 'datetime', null, 'NO', '', 'NULL', '', '', ''],
],
],
[