diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b7fb1fc90e..33268cf1de 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2079,12 +2079,6 @@ parameters: count: 2 path: src/Controllers/Database/StructureController.php - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, int\|string\|null given\.$#' - identifier: argument.type - count: 2 - path: src/Controllers/Database/StructureController.php - - message: '#^Parameter \#1 \$string of function md5 expects string, int\|string\|null given\.$#' identifier: argument.type diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 679944689a..a46add7bfe 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1200,8 +1200,6 @@ - - @@ -1215,6 +1213,9 @@ + + + diff --git a/resources/templates/database/operations/index.twig b/resources/templates/database/operations/index.twig index 2b0150ff67..c1a54a107f 100644 --- a/resources/templates/database/operations/index.twig +++ b/resources/templates/database/operations/index.twig @@ -92,7 +92,7 @@ 'goto': url('/'), 'reload': true, 'purge': true, - 'message_to_show': t('Database %s has been dropped.')|format(backquote(db))|e, + 'message_to_show': t('Database %s has been dropped.')|format(backquote(db)), 'db': null }, t('Drop the database (DROP)'), diff --git a/resources/templates/database/structure/structure_table_row.twig b/resources/templates/database/structure/structure_table_row.twig index 84f4acc94c..d69654e671 100644 --- a/resources/templates/database/structure/structure_table_row.twig +++ b/resources/templates/database/structure/structure_table_row.twig @@ -69,7 +69,7 @@ {{ may_have_rows ? get_icon('b_empty', t('Empty')) : get_icon('bd_empty', t('Empty')) }} diff --git a/resources/templates/table/operations/index.twig b/resources/templates/table/operations/index.twig index 8311884679..ec21a0698b 100644 --- a/resources/templates/table/operations/index.twig +++ b/resources/templates/table/operations/index.twig @@ -124,12 +124,12 @@
-
@@ -378,7 +378,7 @@
  • {{ t('Flush the table (FLUSH)') }} @@ -418,7 +418,7 @@ 'sql_query': 'TRUNCATE TABLE ' ~ backquote(db) ~ '.' ~ backquote(table), 'goto': url('/table/structure'), 'reload': true, - 'message_to_show': t('Table %s has been emptied.')|format(table)|e + 'message_to_show': t('Table %s has been emptied.')|format(table) }), t('Empty the table (TRUNCATE)'), { @@ -436,7 +436,7 @@ 'sql_query': 'DELETE FROM ' ~ backquote(db) ~ '.' ~ backquote(table), 'goto': url('/table/structure'), 'reload': true, - 'message_to_show': t('Table %s has been emptied.')|format(table)|e + 'message_to_show': t('Table %s has been emptied.')|format(table) }), t('Empty the table (DELETE FROM)'), { @@ -456,7 +456,7 @@ 'goto': url('/database/operations'), 'reload': true, 'purge': true, - 'message_to_show': is_view ? t('View %s has been dropped.')|format(table)|e : t('Table %s has been dropped.')|format(table)|e, + 'message_to_show': is_view ? t('View %s has been dropped.')|format(table) : t('Table %s has been dropped.')|format(table), 'table': table }), t('Delete the table (DROP)'), diff --git a/resources/templates/table/operations/view.twig b/resources/templates/table/operations/view.twig index b63262300c..996dceb82f 100644 --- a/resources/templates/table/operations/view.twig +++ b/resources/templates/table/operations/view.twig @@ -33,7 +33,7 @@ 'goto': url('/table/structure'), 'reload': true, 'purge': true, - 'message_to_show': t('View %s has been dropped.')|format(table)|e, + 'message_to_show': t('View %s has been dropped.')|format(table), 'table': table }), t('Delete the view (DROP)'), diff --git a/resources/templates/table/structure/display_structure.twig b/resources/templates/table/structure/display_structure.twig index 94edec6319..b5e8d6479a 100644 --- a/resources/templates/table/structure/display_structure.twig +++ b/resources/templates/table/structure/display_structure.twig @@ -115,7 +115,7 @@ 'sql_query': 'ALTER TABLE ' ~ backquote(table) ~ ' DROP ' ~ backquote(row.field) ~ ';', 'dropped_column': row.field, 'purge': true, - 'message_to_show': t('Column %s has been dropped.')|format(row.field|e) + 'message_to_show': t('Column %s has been dropped.')|format(row.field) }, '', false) }}"> {{ get_icon('b_drop', t('Drop')) }} diff --git a/src/Controllers/Database/StructureController.php b/src/Controllers/Database/StructureController.php index 13cc01f814..7bea9c2bb7 100644 --- a/src/Controllers/Database/StructureController.php +++ b/src/Controllers/Database/StructureController.php @@ -41,7 +41,6 @@ use function __; use function array_search; use function ceil; use function count; -use function htmlspecialchars; use function implode; use function in_array; use function is_string; @@ -51,8 +50,6 @@ use function md5; use function preg_match; use function preg_quote; use function sprintf; -use function str_replace; -use function urlencode; /** * Handles database structure logic @@ -349,11 +346,7 @@ final class StructureController implements InvocableController ); $dropMessage = sprintf( ($tableIsView ? __('View %s has been dropped.') : __('Table %s has been dropped.')), - str_replace( - ' ', - ' ', - htmlspecialchars($currentTable['TABLE_NAME']), - ), + $currentTable['TABLE_NAME'], ); } @@ -393,14 +386,6 @@ final class StructureController implements InvocableController 'browse_table_label_title' => $currentTable['TABLE_COMMENT'], 'browse_table_label_truename' => $truename, 'empty_table_sql_query' => 'TRUNCATE ' . Util::backquote($currentTable['TABLE_NAME']), - 'empty_table_message_to_show' => urlencode( - sprintf( - __('Table %s has been emptied.'), - htmlspecialchars( - $currentTable['TABLE_NAME'], - ), - ), - ), 'tracking_icon' => $this->getTrackingIcon($truename, $trackedTables[$truename] ?? null), 'server_replica_status' => $replicaInfo['status'], 'table_url_params' => $tableUrlParams, @@ -639,8 +624,8 @@ final class StructureController implements InvocableController * @internal param bool $table_is_view whether table is view or not * * @param (string|int|null)[] $currentTable current table - * @param int $sumSize total table size - * @param int $overheadSize overhead size + * @param int $sumSize total table size + * @param int $overheadSize overhead size * * @return list{(string|int|null)[], string, string, string, string, int, bool, int} */ @@ -758,12 +743,12 @@ final class StructureController implements InvocableController * Get values for ARIA/MARIA tables * * @param (string|int|null)[] $currentTable current table - * @param int $sumSize sum size - * @param int $overheadSize overhead size - * @param string $formattedSize formatted size - * @param string $unit unit - * @param string $formattedOverhead overhead formatted - * @param string $overheadUnit overhead unit + * @param int $sumSize sum size + * @param int $overheadSize overhead size + * @param string $formattedSize formatted size + * @param string $unit unit + * @param string $formattedOverhead overhead formatted + * @param string $overheadUnit overhead unit * * @return array{(string|int|null)[], string, string, string, string, int|float, int} */ @@ -800,7 +785,7 @@ final class StructureController implements InvocableController * Get values for InnoDB table * * @param (string|int|null)[] $currentTable current table - * @param int $sumSize sum size + * @param int $sumSize sum size * * @return array{(string|int|null)[], string, string, int} */ @@ -899,7 +884,7 @@ final class StructureController implements InvocableController * Get values for Mroonga table * * @param (string|int|null)[] $currentTable current table - * @param int $sumSize sum size + * @param int $sumSize sum size * * @return array{(string|int|null)[], string, string, int} */ diff --git a/src/Controllers/Sql/SqlController.php b/src/Controllers/Sql/SqlController.php index 1646b45774..f98818fd38 100644 --- a/src/Controllers/Sql/SqlController.php +++ b/src/Controllers/Sql/SqlController.php @@ -162,6 +162,7 @@ readonly class SqlController implements InvocableController ]); } + Current::$messageToShow = $request->getParsedBodyParamAsString('message_to_show', ''); $this->response->addHTML($this->sql->executeQueryAndSendQueryResponse( $statementInfo, $isGotofile,