Skip to content

Commit 17e3414

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2 parents 307d8aa + fc431ea commit 17e3414

15 files changed

Lines changed: 618 additions & 525 deletions

File tree

phpstan-baseline.neon

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4560,13 +4560,13 @@ parameters:
45604560
-
45614561
message: '#^Cannot access property \$name on PhpMyAdmin\\SqlParser\\Components\\DataType\|null\.$#'
45624562
identifier: property.nonObject
4563-
count: 2
4563+
count: 1
45644564
path: src/Database/Routines.php
45654565

45664566
-
45674567
message: '#^Cannot access property \$options on PhpMyAdmin\\SqlParser\\Components\\DataType\|null\.$#'
45684568
identifier: property.nonObject
4569-
count: 2
4569+
count: 1
45704570
path: src/Database/Routines.php
45714571

45724572
-
@@ -4578,7 +4578,7 @@ parameters:
45784578
-
45794579
message: '#^Cannot access property \$parameters on PhpMyAdmin\\SqlParser\\Components\\DataType\|null\.$#'
45804580
identifier: property.nonObject
4581-
count: 3
4581+
count: 2
45824582
path: src/Database/Routines.php
45834583

45844584
-
@@ -4588,9 +4588,9 @@ parameters:
45884588
path: src/Database/Routines.php
45894589

45904590
-
4591-
message: '#^Cannot call method get\(\) on PhpMyAdmin\\SqlParser\\Components\\OptionsArray\|null\.$#'
4591+
message: '#^Cannot call method has\(\) on PhpMyAdmin\\SqlParser\\Components\\OptionsArray\|null\.$#'
45924592
identifier: method.nonObject
4593-
count: 1
4593+
count: 2
45944594
path: src/Database/Routines.php
45954595

45964596
-
@@ -4623,6 +4623,12 @@ parameters:
46234623
count: 4
46244624
path: src/Database/Routines.php
46254625

4626+
-
4627+
message: '#^PHPDoc tag @var with type string\|false is not subtype of type bool\.$#'
4628+
identifier: varTag.type
4629+
count: 2
4630+
path: src/Database/Routines.php
4631+
46264632
-
46274633
message: '#^Parameter \#1 \$alias of method PhpMyAdmin\\Types\:\:mapAliasToMysqlType\(\) expects string, mixed given\.$#'
46284634
identifier: argument.type
@@ -4899,6 +4905,12 @@ parameters:
48994905
count: 1
49004906
path: src/Dbal/DatabaseInterface.php
49014907

4908+
-
4909+
message: '#^Parameter \#1 \$mode of static method PhpMyAdmin\\SqlParser\\Context\:\:setMode\(\) expects int\|string, string\|null given\.$#'
4910+
identifier: argument.type
4911+
count: 1
4912+
path: src/Dbal/DatabaseInterface.php
4913+
49024914
-
49034915
message: '#^Parameter \#1 \$path of function basename expects string, mixed given\.$#'
49044916
identifier: argument.type
@@ -7161,7 +7173,7 @@ parameters:
71617173
-
71627174
message: '#^Cannot access offset mixed on mixed\.$#'
71637175
identifier: offsetAccess.nonOffsetAccessible
7164-
count: 1
7176+
count: 2
71657177
path: src/Indexes/Index.php
71667178

71677179
-
@@ -12238,11 +12250,17 @@ parameters:
1223812250
path: src/Table/Indexes.php
1223912251

1224012252
-
12241-
message: '#^Only booleans are allowed in a negated boolean, int\|null given\.$#'
12253+
message: '#^Only booleans are allowed in a negated boolean, string\|null given\.$#'
1224212254
identifier: booleanNot.exprNotBoolean
1224312255
count: 1
1224412256
path: src/Table/Indexes.php
1224512257

12258+
-
12259+
message: '#^Only booleans are allowed in an if condition, int\|null given\.$#'
12260+
identifier: if.condNotBoolean
12261+
count: 1
12262+
path: src/Table/Indexes.php
12263+
1224612264
-
1224712265
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
1224812266
identifier: foreach.nonIterable

psalm-baseline.xml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,13 +3381,10 @@
33813381
<MixedArgumentTypeCoercion>
33823382
<code><![CDATA[$itemParamDir]]></code>
33833383
<code><![CDATA[$itemParamName]]></code>
3384-
<code><![CDATA[$options]]></code>
3385-
<code><![CDATA[$options]]></code>
33863384
<code><![CDATA[$retval['item_param_opts_num'][$idx]]]></code>
33873385
<code><![CDATA[$value]]></code>
33883386
</MixedArgumentTypeCoercion>
33893387
<MixedArrayAccess>
3390-
<code><![CDATA[$opt['value']]]></code>
33913388
<code><![CDATA[$opt['value']]]></code>
33923389
<code><![CDATA[$routine['item_param_dir'][$i]]]></code>
33933390
<code><![CDATA[$routine['item_param_dir'][$i]]]></code>
@@ -3431,8 +3428,6 @@
34313428
<code><![CDATA[$itemParamName]]></code>
34323429
<code><![CDATA[$itemParamType]]></code>
34333430
<code><![CDATA[$opt]]></code>
3434-
<code><![CDATA[$opt]]></code>
3435-
<code><![CDATA[$options[]]]></code>
34363431
<code><![CDATA[$retval['item_param_opts_num'][$idx][]]]></code>
34373432
<code><![CDATA[$value]]></code>
34383433
<code><![CDATA[$value]]></code>
@@ -3491,11 +3486,9 @@
34913486
<code><![CDATA[$param->type->parameters]]></code>
34923487
<code><![CDATA[$routine['SPECIFIC_NAME']]]></code>
34933488
<code><![CDATA[$routine['SPECIFIC_NAME']]]></code>
3494-
<code><![CDATA[$stmt->return->parameters]]></code>
34953489
</PossiblyNullArgument>
34963490
<PossiblyNullIterator>
34973491
<code><![CDATA[$param->type->options->options]]></code>
3498-
<code><![CDATA[$stmt->return->options->options]]></code>
34993492
</PossiblyNullIterator>
35003493
<PossiblyNullOperand>
35013494
<code><![CDATA[$_POST['item_original_type']]]></code>
@@ -3505,13 +3498,9 @@
35053498
<code><![CDATA[$param->type->options]]></code>
35063499
<code><![CDATA[$param->type->options->options]]></code>
35073500
<code><![CDATA[$param->type->parameters]]></code>
3508-
<code><![CDATA[$stmt->return->name]]></code>
3509-
<code><![CDATA[$stmt->return->options]]></code>
3510-
<code><![CDATA[$stmt->return->options->options]]></code>
3511-
<code><![CDATA[$stmt->return->parameters]]></code>
35123501
</PossiblyNullPropertyFetch>
35133502
<PossiblyNullReference>
3514-
<code><![CDATA[get]]></code>
3503+
<code><![CDATA[has]]></code>
35153504
</PossiblyNullReference>
35163505
<PossiblyUndefinedArrayOffset>
35173506
<code><![CDATA[$_POST['item_original_type']]]></code>
@@ -3633,6 +3622,7 @@
36333622
</PossiblyInvalidOperand>
36343623
<PossiblyNullArgument>
36353624
<code><![CDATA[$_SERVER['SCRIPT_NAME']]]></code>
3625+
<code><![CDATA[$version['@@sql_mode']]]></code>
36363626
</PossiblyNullArgument>
36373627
<PossiblyNullArrayAccess>
36383628
<code><![CDATA[$resultTarget[]]]></code>
@@ -5005,9 +4995,11 @@
50054995
<code><![CDATA[$params['columns']]]></code>
50064996
</MixedArgument>
50074997
<MixedArrayOffset>
4998+
<code><![CDATA[$columns['collations'][$key]]]></code>
50084999
<code><![CDATA[$columns['sub_parts'][$key]]]></code>
50095000
</MixedArrayOffset>
50105001
<MixedAssignment>
5002+
<code><![CDATA[$collation]]></code>
50115003
<code><![CDATA[$column]]></code>
50125004
<code><![CDATA[$key]]></code>
50135005
<code><![CDATA[$name]]></code>
@@ -8048,7 +8040,8 @@
80488040
<code><![CDATA[$column->getSubPart()]]></code>
80498041
</PossiblyNullOperand>
80508042
<RiskyTruthyFalsyComparison>
8051-
<code><![CDATA[! $column->getSubPart()]]></code>
8043+
<code><![CDATA[! $column->getCollation()]]></code>
8044+
<code><![CDATA[$column->getSubPart()]]></code>
80528045
</RiskyTruthyFalsyComparison>
80538046
</file>
80548047
<file src="src/Table/Search.php">

resources/js/makegrid.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,10 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine
753753

754754
// remove decimal places if column type not supported
755755
if ((decimals === 0) && ($thisField.attr('data-type').indexOf('time') !== -1)) {
756-
newHtml = newHtml.substring(0, newHtml.indexOf('.'));
756+
var index = newHtml.indexOf('.');
757+
if (index !== -1) {
758+
newHtml = newHtml.substring(0, index);
759+
}
757760
}
758761

759762
// remove additional decimal places

resources/templates/database/routines/editor_form.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<option value="">{{ t('Charset') }}</option>
100100
<option value=""></option>
101101
{% for charset in charsets %}
102-
<option value="{{ charset.getName() }}" title="{{ charset.getDescription() }}"{{ routine.item_returnopts_text == charset.getName() ? ' selected' }}>{{ charset.getName() }}</option>
102+
<option value="{{ charset.getName() }}" title="{{ charset.getDescription() }}"{{ routine.item_returnopts_text|lower == charset.getName() ? ' selected' }}>{{ charset.getName() }}</option>
103103
{% endfor %}
104104
</select>
105105
</div>

resources/templates/table/index_form.twig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
<th>
144144
{{ t('Size') }}
145145
</th>
146+
<th>
147+
{{ t('Collation') }}
148+
</th>
146149
</tr>
147150
</thead>
148151
{% set spatial_types = [
@@ -190,6 +193,13 @@
190193
value="{{ index.getChoice() != 'SPATIAL' ?
191194
column.getSubPart() }}">
192195
</td>
196+
<td>
197+
<select name="index[columns][collations][]">
198+
<option value=""{{ column.Collation ? ' selected' }}>{{ t('None') }}</option>
199+
<option value="A"{{ column.Collation == 'A' ? ' selected' }} title="ASC">A</option>
200+
<option value="D"{{ column.Collation == 'D' ? ' selected' }} title="DESC">D</option>
201+
</select>
202+
</td>
193203
</tr>
194204
{% endfor %}
195205
{% if add_fields > 0 %}
@@ -223,6 +233,13 @@
223233
name="index[columns][sub_parts][]"
224234
value="">
225235
</td>
236+
<td>
237+
<select name="index[columns][collations][]">
238+
<option value="" selected>{{ t('None') }}</option>
239+
<option value="A" title="ASC">A</option>
240+
<option value="D" title="DESC">D</option>
241+
</select>
242+
</td>
226243
</tr>
227244
{% endfor %}
228245
{% endif %}

src/Controllers/Database/EventsController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ public function __invoke(ServerRequest $request): Response
6262
if ($request->isAjax()) {
6363
if (Current::$message instanceof Message && Current::$message->isSuccess()) {
6464
$events = $this->events->getDetails(Current::$database, $_POST['item_name']);
65+
if ($events === []) {
66+
$this->response->setRequestStatus(false);
67+
$this->response->addJSON(
68+
'message',
69+
__('The event was dropped immediately after creation.'),
70+
);
71+
$this->response->addJSON('tableType', 'events');
72+
73+
return $this->response->response();
74+
}
75+
6576
$event = $events[0];
6677
$this->response->addJSON(
6778
'name',

src/Database/Routines.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,34 @@ public function getDataFromName(string $name, string $type, bool $all = true): a
479479
$retval['item_returnopts_num'] = '';
480480
$retval['item_returnopts_text'] = '';
481481

482-
if (! empty($routine['DTD_IDENTIFIER'])) {
483-
$options = [];
482+
if (! empty($routine['DTD_IDENTIFIER']) && $stmt->return !== null) {
483+
$retval['item_returntype'] = $stmt->return->name;
484+
$retval['item_returnlength'] = implode(',', $stmt->return->parameters);
485+
486+
// Extract charset (CHARSET or CHARACTER SET) separately from numeric options
487+
/** @var string|false $charset */
488+
$charset = $stmt->return->options->has('CHARSET');
489+
if ($charset === false) {
490+
/** @var string|false $charset */
491+
$charset = $stmt->return->options->has('CHARACTER SET');
492+
}
493+
494+
$retval['item_returnopts_text'] = is_string($charset) ? mb_strtolower($charset) : '';
495+
496+
// Extract numeric options (UNSIGNED, ZEROFILL, UNSIGNED ZEROFILL.)
497+
$numericOpts = [];
484498
foreach ($stmt->return->options->options as $opt) {
485-
$options[] = is_string($opt) ? $opt : $opt['value'];
499+
if (! is_string($opt) || ! in_array($opt, $this->numericOptions, true)) {
500+
continue;
501+
}
502+
503+
$numericOpts[] = $opt;
486504
}
487505

488-
$retval['item_returntype'] = $stmt->return->name;
489-
$retval['item_returnlength'] = implode(',', $stmt->return->parameters);
490-
$retval['item_returnopts_num'] = implode(' ', $options);
491-
$retval['item_returnopts_text'] = implode(' ', $options);
506+
$retval['item_returnopts_num'] = implode(' ', $numericOpts);
492507
}
493508

494-
$retval['item_definer'] = $stmt->options->get('DEFINER');
509+
$retval['item_definer'] = $stmt->options?->has('DEFINER') ?? false;
495510
$retval['item_definition'] = $body;
496511
$retval['item_isdeterministic'] = '';
497512
if ($routine['IS_DETERMINISTIC'] === 'YES') {

src/Dbal/DatabaseInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,10 +1032,11 @@ public function getDefaultCollation(): string
10321032
*/
10331033
public function postConnect(Server $currentServer): void
10341034
{
1035-
$version = $this->fetchSingleRow('SELECT @@version, @@version_comment');
1035+
$version = $this->fetchSingleRow('SELECT @@version, @@version_comment, @@sql_mode');
10361036

10371037
if ($version !== []) {
10381038
$this->setVersion($version);
1039+
Context::setMode($version['@@sql_mode']);
10391040
}
10401041

10411042
$this->query(

src/Indexes/Index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,11 @@ public function addColumns(array $columns): void
231231
// coming from form
232232
// $columns[names][]
233233
// $columns[sub_parts][]
234+
// $columns[collations][]
234235
foreach ($columns['names'] as $key => $name) {
235236
$subPart = $columns['sub_parts'][$key] ?? '';
236-
$addedColumns[] = ['Column_name' => $name, 'Sub_part' => $subPart];
237+
$collation = $columns['collations'][$key] ?? null;
238+
$addedColumns[] = ['Column_name' => $name, 'Sub_part' => $subPart, 'Collation' => $collation];
237239
}
238240
} else {
239241
// coming from SHOW INDEXES

src/Indexes/IndexColumn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class IndexColumn
1717
/** @var int The column sequence number in the index, starting with 1. */
1818
private int $seqInIndex = 1;
1919

20-
/** @var string|null How the column is sorted in the index. "A" (Ascending) or NULL (Not sorted) */
20+
/** @var string|null How the column is sorted in the index. "A" (Ascending), "D" (Descending) or NULL (Not sorted) */
2121
private string|null $collation = null;
2222

2323
/**

0 commit comments

Comments
 (0)