diff --git a/libraries/classes/ColumnFull.php b/libraries/classes/ColumnFull.php new file mode 100644 index 0000000000..06536b56d8 --- /dev/null +++ b/libraries/classes/ColumnFull.php @@ -0,0 +1,21 @@ +dbi->getColumns($db, $table, true); foreach ($columns as $column) { - if (empty($column['Comment'])) { + if ($column['Comment'] === '') { continue; } diff --git a/libraries/classes/Controllers/Database/DataDictionaryController.php b/libraries/classes/Controllers/Database/DataDictionaryController.php index 322d0b0e95..8588a7e1e7 100644 --- a/libraries/classes/Controllers/Database/DataDictionaryController.php +++ b/libraries/classes/Controllers/Database/DataDictionaryController.php @@ -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, diff --git a/libraries/classes/Controllers/Table/ChangeController.php b/libraries/classes/Controllers/Table/ChangeController.php index 5d49e387aa..92f5173de6 100644 --- a/libraries/classes/Controllers/Table/ChangeController.php +++ b/libraries/classes/Controllers/Table/ChangeController.php @@ -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; } diff --git a/libraries/classes/Controllers/Table/FindReplaceController.php b/libraries/classes/Controllers/Table/FindReplaceController.php index 9e639cbba8..d67c61c586 100644 --- a/libraries/classes/Controllers/Table/FindReplaceController.php +++ b/libraries/classes/Controllers/Table/FindReplaceController.php @@ -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); diff --git a/libraries/classes/Controllers/Table/SearchController.php b/libraries/classes/Controllers/Table/SearchController.php index 763544ac95..37fb6fd7ab 100644 --- a/libraries/classes/Controllers/Table/SearchController.php +++ b/libraries/classes/Controllers/Table/SearchController.php @@ -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 diff --git a/libraries/classes/Controllers/Table/Structure/ChangeController.php b/libraries/classes/Controllers/Table/Structure/ChangeController.php index e9a1a7519a..37aa2f9d06 100644 --- a/libraries/classes/Controllers/Table/Structure/ChangeController.php +++ b/libraries/classes/Controllers/Table/Structure/ChangeController.php @@ -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!'), ); diff --git a/libraries/classes/Controllers/Table/ZoomSearchController.php b/libraries/classes/Controllers/Table/ZoomSearchController.php index a9a37036a4..375ba4a977 100644 --- a/libraries/classes/Controllers/Table/ZoomSearchController.php +++ b/libraries/classes/Controllers/Table/ZoomSearchController.php @@ -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 diff --git a/libraries/classes/Database/CentralColumns.php b/libraries/classes/Database/CentralColumns.php index 8f53e0a89e..3de1dd9d92 100644 --- a/libraries/classes/Database/CentralColumns.php +++ b/libraries/classes/Database/CentralColumns.php @@ -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); diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php index 36deed9ca0..2f4e81aa80 100644 --- a/libraries/classes/DatabaseInterface.php +++ b/libraries/classes/DatabaseInterface.php @@ -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 $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, diff --git a/libraries/classes/Dbal/DbalInterface.php b/libraries/classes/Dbal/DbalInterface.php index 21082e13dd..e5fceb7472 100644 --- a/libraries/classes/Dbal/DbalInterface.php +++ b/libraries/classes/Dbal/DbalInterface.php @@ -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, diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index a0429bdff4..818767892a 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -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 '' - . htmlspecialchars($column['Field']) . ''; + . htmlspecialchars($commentsMap[$fieldName]) . '">' + . htmlspecialchars($fieldName) . ''; } - 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 */ 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 $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, diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index 14b4674a34..c6b4011ebb 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -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']; diff --git a/libraries/classes/Plugins/Export/ExportLatex.php b/libraries/classes/Plugins/Export/ExportLatex.php index bddaf7fb3c..0dc867edfa 100644 --- a/libraries/classes/Plugins/Export/ExportLatex.php +++ b/libraries/classes/Plugins/Export/ExportLatex.php @@ -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) { diff --git a/libraries/classes/Plugins/Export/Helpers/Pdf.php b/libraries/classes/Plugins/Export/Helpers/Pdf.php index 3f8dad6824..d12b2a7e2d 100644 --- a/libraries/classes/Plugins/Export/Helpers/Pdf.php +++ b/libraries/classes/Plugins/Export/Helpers/Pdf.php @@ -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'] ?? ''; diff --git a/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php b/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php index 98305dda0c..1d2de2b383 100644 --- a/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php +++ b/libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php @@ -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'] ?? '', diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index dd5c9219f7..a30c940e57 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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\\\\|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\\\\|null\\.$#" + count: 1 + path: libraries/classes/DatabaseInterface.php + - message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumnNames\\(\\) should return array\\ but returns array\\.$#" count: 1 path: libraries/classes/DatabaseInterface.php + - + message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumns\\(\\) should return array\\ but returns array\\\\>\\.$#" + 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\\ will always evaluate to true\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d3477db10a..3ac8955e3d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -744,7 +744,6 @@ - $foreign[$field] $foreign[$field] $foreign[$key] @@ -754,7 +753,6 @@ $childReferences $column $columns - $field $foreignDb $foreignField @@ -803,6 +801,10 @@ $foreigners + + + + getDbComments @@ -959,17 +961,6 @@ - - - - - - - - - - - $relation @@ -3650,7 +3641,6 @@ - $foreignDb $foreignTable $html @@ -3660,20 +3650,14 @@ : []]]> - - - - - - $existrelForeign $foreignDb $foreignTable @@ -4181,7 +4165,6 @@ $attributes[$rownum] $columnsList[] $field - $rowComments[$rownum] @@ -4754,7 +4737,6 @@ $default - $field $key @@ -4846,7 +4828,6 @@ $defaultValue $defaultValues[$rowNum] $extra - $field $hasList[] $key $length @@ -4901,6 +4882,9 @@ $db $table + + $field + @@ -5526,9 +5510,6 @@ tablesNamesOnly)]]> - - - searchTypeDescription]]> @@ -5759,6 +5740,7 @@ reset($columns) + attachIndexInfoToColumns($database, $table, $fields)]]> fetchResult($sql, null, 'Field', $connectionType)]]> fetchResult($sql, null, null, $connectionType)]]> ]]> + array_shift($columns) + + string[] @@ -7606,9 +7611,6 @@ - - - @@ -7619,15 +7621,11 @@ - - - - $currCellEditedValues[$columnName] @@ -7674,8 +7672,6 @@ - - @@ -7698,12 +7694,9 @@ - - $columnSetValues - $currCellEditedValues @@ -7775,6 +7768,9 @@ + + + @@ -8230,9 +8226,6 @@ $col - - - $dependent $dependents $dependents @@ -8297,10 +8290,6 @@ - - - - (string) $dependon @@ -8922,7 +8911,6 @@ $comments[$fieldName] - $fieldName @@ -8938,21 +8926,12 @@ - - - - $comments[$fieldName] - $mimeMap[$fieldName] - $colAlias $colAs $colAs $colAs - $colAs - $colAs - $fieldName $trigger $value @@ -9001,29 +8980,21 @@ $columnsAlias[$i] $escape[$k] - $fieldName - - - - - $colAs $colAs $colAs $columnsAlias[$i] - $fieldName $type $colAs $comments[$fieldName] $escape[$k] - $type @@ -9059,21 +9030,13 @@ - - - - $colAs $colAs $column $colAs $column - - - - $doComments @@ -9081,6 +9044,7 @@ $doRelation + $row[$i] $tableAlias $tableAlias @@ -9127,7 +9091,6 @@ $comments[$fieldName] - $fieldName @@ -9145,8 +9108,6 @@ - - @@ -9154,9 +9115,6 @@ $colAs $colAs $colAs - $colAs - $colAs - $fieldName $rfield $rfield $rtable @@ -9280,9 +9238,6 @@ $colAlias $colAlias $colAs - - - $engine $eventName $eventName @@ -9318,7 +9273,6 @@ - @@ -9331,7 +9285,6 @@ $colAlias $colAlias - $colAlias $colAs $columnAliases $definition @@ -9353,8 +9306,6 @@ $trigger - - entityOptions->has('AUTO_INCREMENT')]]> @@ -9436,7 +9387,6 @@ $comments[$fieldName] - $fieldName $type @@ -9451,21 +9401,12 @@ - - - - $comments[$fieldName] - $mimeMap[$fieldName] - $colAlias $colAs $colAs $colAs - $colAs - $colAs - $fieldName $trigger $type $value @@ -9575,7 +9516,6 @@ tMargin]]> $cellFontSize $colAs - $fullwidth + $l $fullwidth + $l $fullwidth + $l @@ -9674,10 +9614,6 @@ - $comments[$fieldName] - $mimeMap[$fieldName] - $resRel[$fieldName] - $resRel[$fieldName] headerset[$this->page]]]> headerset[$this->page]]]> pagedim[$oldpage]]]> @@ -9705,9 +9641,6 @@ $data[] $data[] $data[] - $data[] - $data[] - $fieldName $fullwidth $fullwidth $fullwidth @@ -10744,15 +10677,12 @@ diagram->PageNo()]]> - $fieldName - $fieldName $oneField - @@ -10804,19 +10734,14 @@ diagram->customLinks['RT'][$table]]]> - diagram->customLinks['RT'][$table][$fieldName]]]> diagram->customLinks['doc'][$foreigner['foreign_table']]]]> diagram->customLinks['doc'][$foreigner['foreign_table']]]]> diagram->customLinks['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']]]]> diagram->customLinks['doc'][$table]]]> diagram->customLinks['doc'][$table]]]> - diagram->customLinks['doc'][$table][$fieldName]]]> - diagram->customLinks['doc'][$table][$fieldName]]]> $attribute - $fieldName - $fieldName $foreignTable $index $links[0] @@ -10848,9 +10773,6 @@ - - - isWithDataDictionary @@ -11571,8 +11493,6 @@ $errorMessage $serverReplicationVariable $successMessage - - @@ -12309,7 +12229,6 @@ - @@ -13355,7 +13274,6 @@ $array $columnNames[] - $columnNames[] diff --git a/test/classes/Controllers/Table/StructureControllerTest.php b/test/classes/Controllers/Table/StructureControllerTest.php index 5f12d1bb96..f8f03b8dd8 100644 --- a/test/classes/Controllers/Table/StructureControllerTest.php +++ b/test/classes/Controllers/Table/StructureControllerTest.php @@ -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' => [], diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index a36373be94..1b0a211b31 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -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<', ); @@ -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( [], diff --git a/test/classes/Stubs/DbiDummy.php b/test/classes/Stubs/DbiDummy.php index f7aa0ed294..d0555cbec3 100644 --- a/test/classes/Stubs/DbiDummy.php +++ b/test/classes/Stubs/DbiDummy.php @@ -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', '', '', ''], ], ], [