Fix message_to_show

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2025-12-08 14:32:39 +00:00
parent b82b20187a
commit d9426e17e4
9 changed files with 27 additions and 46 deletions

View File

@ -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

View File

@ -1200,8 +1200,6 @@
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
<code><![CDATA[$truename]]></code>
<code><![CDATA[$truename]]></code>
</PossiblyInvalidArgument>
@ -1215,6 +1213,9 @@
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
</PossiblyInvalidOperand>
<PossiblyNullArgument>
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
</PossiblyNullArgument>
<PossiblyNullOperand>
<code><![CDATA[$columnNames]]></code>
<code><![CDATA[$currentTable['Data_length']]]></code>

View File

@ -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)'),

View File

@ -69,7 +69,7 @@
<td class="text-center d-print-none">
<a class="truncate_table_anchor ajax" href="{{ url('/sql') }}" data-post="{{ get_common(table_url_params|merge({
'sql_query': empty_table_sql_query,
'message_to_show': empty_table_message_to_show
'message_to_show': t('Table %s has been emptied.')|format(current_table['TABLE_NAME']),
}), '') }}">
{{ may_have_rows ? get_icon('b_empty', t('Empty')) : get_icon('bd_empty', t('Empty')) }}
</a>

View File

@ -124,12 +124,12 @@
<label for="tableCommentsInput">{{ t('Table comments') }}</label>
</div>
<div class="col-6">
<textarea
<textarea
id="tableCommentsInput"
class="form-control"
name="comment"
maxlength="2048"
class="textfield"
name="comment"
maxlength="2048"
class="textfield"
rows="1"
cols="30">{{ table_comment }}</textarea>
</div>
@ -378,7 +378,7 @@
<li class="list-group-item">
<a class="maintain_action ajax" href="{{ url('/sql') }}" data-post="{{ get_common(url_params|merge({
'sql_query': 'FLUSH TABLE ' ~ backquote(table),
'message_to_show': t('Table %s has been flushed.')|format(table|e),
'message_to_show': t('Table %s has been flushed.')|format(table),
'reload': true
}), '', false) }}">
{{ 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)'),

View File

@ -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)'),

View File

@ -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')) }}
</a>

View File

@ -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(
' ',
'&nbsp;',
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}
*/

View File

@ -162,6 +162,7 @@ readonly class SqlController implements InvocableController
]);
}
Current::$messageToShow = $request->getParsedBodyParamAsString('message_to_show', '');
$this->response->addHTML($this->sql->executeQueryAndSendQueryResponse(
$statementInfo,
$isGotofile,