Skip to content

Commit f665e50

Browse files
committed
Merge branch 'QA_5_2'
2 parents 9584a4b + b415422 commit f665e50

13 files changed

Lines changed: 275 additions & 300 deletions

File tree

‎ChangeLog‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ phpMyAdmin - ChangeLog
8484
- issue #18049 Also check that curl_exec is enabled for the new version check
8585
- issue #18451 Fix when editing inline central column, Null is always preselected
8686
- issue #19117 Allow changing the virtuality of a column without any other changes
87+
- issue #18566 Fixed error when importing exported view with USE INDEX hint
88+
- issue #17920 Fixed moving column with empty default value will replace it with ''
89+
- issue #18006 Fixed moving columns causes the default uuid() value to get quotes around it
90+
- issue #18962 Fixed move columns with ENUM() & DEFAULT causes invalid SQL
8791

8892
5.2.1 (2023-02-07)
8993
- issue #17522 Fix case where the routes cache file is invalid

‎phpstan-baseline.neon‎

Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,11 +2805,6 @@ parameters:
28052805
count: 1
28062806
path: src/Controllers/LicenseController.php
28072807

2808-
-
2809-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
2810-
count: 3
2811-
path: src/Controllers/LintController.php
2812-
28132808
-
28142809
message: "#^Parameter \\#1 \\$database of method PhpMyAdmin\\\\Navigation\\\\Navigation\\:\\:getItemUnhideDialog\\(\\) expects string, mixed given\\.$#"
28152810
count: 1
@@ -5065,121 +5060,6 @@ parameters:
50655060
count: 1
50665061
path: src/Controllers/Table/Structure/ChangeController.php
50675062

5068-
-
5069-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
5070-
count: 1
5071-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5072-
5073-
-
5074-
message: "#^Cannot access offset 'COLUMN_COMMENT' on mixed\\.$#"
5075-
count: 1
5076-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5077-
5078-
-
5079-
message: "#^Cannot access offset 'Collation' on mixed\\.$#"
5080-
count: 1
5081-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5082-
5083-
-
5084-
message: "#^Cannot access offset 'Default' on mixed\\.$#"
5085-
count: 5
5086-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5087-
5088-
-
5089-
message: "#^Cannot access offset 'Expression' on mixed\\.$#"
5090-
count: 3
5091-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5092-
5093-
-
5094-
message: "#^Cannot access offset 'Extra' on mixed\\.$#"
5095-
count: 3
5096-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5097-
5098-
-
5099-
message: "#^Cannot access offset 'Null' on mixed\\.$#"
5100-
count: 2
5101-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5102-
5103-
-
5104-
message: "#^Cannot access offset 'Type' on mixed\\.$#"
5105-
count: 3
5106-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5107-
5108-
-
5109-
message: "#^Cannot access offset 'Virtuality' on mixed\\.$#"
5110-
count: 3
5111-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5112-
5113-
-
5114-
message: "#^Parameter \\#1 \\$column of method PhpMyAdmin\\\\Table\\\\Table\\:\\:getColumnGenerationExpression\\(\\) expects string\\|null, mixed given\\.$#"
5115-
count: 1
5116-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5117-
5118-
-
5119-
message: "#^Parameter \\#1 \\$columnSpecification of static method PhpMyAdmin\\\\Util\\:\\:extractColumnSpec\\(\\) expects string, mixed given\\.$#"
5120-
count: 1
5121-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5122-
5123-
-
5124-
message: "#^Parameter \\#1 \\$oldcol of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5125-
count: 1
5126-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5127-
5128-
-
5129-
message: "#^Parameter \\#1 \\$string of function mb_strtoupper expects string, mixed given\\.$#"
5130-
count: 1
5131-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5132-
5133-
-
5134-
message: "#^Parameter \\#10 \\$extra of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5135-
count: 1
5136-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5137-
5138-
-
5139-
message: "#^Parameter \\#11 \\$comment of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5140-
count: 1
5141-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5142-
5143-
-
5144-
message: "#^Parameter \\#12 \\$virtuality of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5145-
count: 1
5146-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5147-
5148-
-
5149-
message: "#^Parameter \\#13 \\$expression of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5150-
count: 1
5151-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5152-
5153-
-
5154-
message: "#^Parameter \\#14 \\$moveTo of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5155-
count: 1
5156-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5157-
5158-
-
5159-
message: "#^Parameter \\#2 \\$newcol of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5160-
count: 1
5161-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5162-
5163-
-
5164-
message: "#^Parameter \\#4 \\$length of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5165-
count: 1
5166-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5167-
5168-
-
5169-
message: "#^Parameter \\#5 \\$attribute of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5170-
count: 1
5171-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5172-
5173-
-
5174-
message: "#^Parameter \\#6 \\$collation of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5175-
count: 1
5176-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5177-
5178-
-
5179-
message: "#^Parameter \\#9 \\$defaultValue of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:generateAlter\\(\\) expects string, mixed given\\.$#"
5180-
count: 1
5181-
path: src/Controllers/Table/Structure/MoveColumnsController.php
5182-
51835063
-
51845064
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
51855065
count: 16
@@ -9020,11 +8900,6 @@ parameters:
90208900
count: 1
90218901
path: src/Linter.php
90228902

9023-
-
9024-
message: "#^Parameter \\#1 \\$lines of static method PhpMyAdmin\\\\Linter\\:\\:findLineNumberAndColumn\\(\\) expects array\\<int, int\\>, array\\<int\\> given\\.$#"
9025-
count: 2
9026-
path: src/Linter.php
9027-
90288903
-
90298904
message: "#^Parameter \\#2 \\$pos of static method PhpMyAdmin\\\\Linter\\:\\:findLineNumberAndColumn\\(\\) expects int, mixed given\\.$#"
90308905
count: 1
@@ -10712,7 +10587,7 @@ parameters:
1071210587

1071310588
-
1071410589
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
10715-
count: 41
10590+
count: 42
1071610591
path: src/Plugins/Export/ExportSql.php
1071710592

1071810593
-

‎psalm-baseline.xml‎

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,7 @@
20802080
</file>
20812081
<file src="src/Controllers/LintController.php">
20822082
<MixedAssignment>
2083+
<code><![CDATA[$editorType]]></code>
20832084
<code><![CDATA[$options]]></code>
20842085
</MixedAssignment>
20852086
<PossiblyUnusedReturnValue>
@@ -3993,56 +3994,6 @@
39933994
<code><![CDATA[[$request->getParam('field')]]]></code>
39943995
</MixedArgumentTypeCoercion>
39953996
</file>
3996-
<file src="src/Controllers/Table/Structure/MoveColumnsController.php">
3997-
<MixedArgument>
3998-
<code><![CDATA[$column]]></code>
3999-
<code><![CDATA[$column]]></code>
4000-
<code><![CDATA[$column]]></code>
4001-
<code><![CDATA[$data['COLUMN_COMMENT'] ?? '']]></code>
4002-
<code><![CDATA[$data['Collation'] ?? '']]></code>
4003-
<code><![CDATA[$data['Default'] ?? '']]></code>
4004-
<code><![CDATA[$data['Expression']]]></code>
4005-
<code><![CDATA[$data['Extra'] ?? '']]></code>
4006-
<code><![CDATA[$data['Type']]]></code>
4007-
<code><![CDATA[$data['Virtuality']]]></code>
4008-
<code><![CDATA[$extractedColumnSpec['attribute']]]></code>
4009-
<code><![CDATA[$extractedColumnSpec['spec_in_brackets']]]></code>
4010-
<code><![CDATA[$extractedColumnSpec['type']]]></code>
4011-
<code><![CDATA[$i === 0 ? '-first' : $columnNames[$i - 1]]]></code>
4012-
</MixedArgument>
4013-
<MixedArrayAccess>
4014-
<code><![CDATA[$data['COLUMN_COMMENT']]]></code>
4015-
<code><![CDATA[$data['Collation']]]></code>
4016-
<code><![CDATA[$data['Default']]]></code>
4017-
<code><![CDATA[$data['Default']]]></code>
4018-
<code><![CDATA[$data['Expression']]]></code>
4019-
<code><![CDATA[$data['Extra']]]></code>
4020-
<code><![CDATA[$data['Null']]]></code>
4021-
<code><![CDATA[$data['Null']]]></code>
4022-
<code><![CDATA[$data['Type']]]></code>
4023-
<code><![CDATA[$data['Type']]]></code>
4024-
<code><![CDATA[$data['Virtuality']]]></code>
4025-
</MixedArrayAccess>
4026-
<MixedArrayAssignment>
4027-
<code><![CDATA[$data['Expression']]]></code>
4028-
<code><![CDATA[$data['Virtuality']]]></code>
4029-
</MixedArrayAssignment>
4030-
<MixedArrayOffset>
4031-
<code><![CDATA[$columns[$column]]]></code>
4032-
</MixedArrayOffset>
4033-
<MixedAssignment>
4034-
<code><![CDATA[$column]]></code>
4035-
<code><![CDATA[$data]]></code>
4036-
<code><![CDATA[$data['Expression']]]></code>
4037-
</MixedAssignment>
4038-
<PossiblyNullArgument>
4039-
<code><![CDATA[$data['Expression']]]></code>
4040-
<code><![CDATA[$data['Extra'] ?? '']]></code>
4041-
</PossiblyNullArgument>
4042-
<PossiblyUnusedMethod>
4043-
<code><![CDATA[__construct]]></code>
4044-
</PossiblyUnusedMethod>
4045-
</file>
40463997
<file src="src/Controllers/Table/Structure/PartitioningController.php">
40473998
<PossiblyNullArgument>
40483999
<code><![CDATA[$stmt->partitions]]></code>
@@ -6961,10 +6912,6 @@
69616912
</RiskyTruthyFalsyComparison>
69626913
</file>
69636914
<file src="src/Linter.php">
6964-
<ArgumentTypeCoercion>
6965-
<code><![CDATA[$lines]]></code>
6966-
<code><![CDATA[$lines]]></code>
6967-
</ArgumentTypeCoercion>
69686915
<InvalidOperand>
69696916
<code><![CDATA[$error[3]]]></code>
69706917
</InvalidOperand>
@@ -8432,6 +8379,7 @@
84328379
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
84338380
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
84348381
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
8382+
<code><![CDATA[empty($GLOBALS['sql_views_as_tables'])]]></code>
84358383
<code><![CDATA[empty($column->collation)]]></code>
84368384
<code><![CDATA[empty($delimiter)]]></code>
84378385
<code><![CDATA[empty($engine)]]></code>
@@ -14547,6 +14495,9 @@
1454714495
<PossiblyUndefinedArrayOffset>
1454814496
<code><![CDATA[$GLOBALS['sql_constraints']]]></code>
1454914497
</PossiblyUndefinedArrayOffset>
14498+
<UnusedMethodCall>
14499+
<code><![CDATA[setAccessible]]></code>
14500+
</UnusedMethodCall>
1455014501
</file>
1455114502
<file src="tests/unit/Plugins/Export/ExportTexytextTest.php">
1455214503
<DeprecatedMethod>

‎resources/js/src/database/events.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ const DatabaseEvents = {
381381
*/
382382
var $elm = $('textarea[name=item_definition]').last();
383383
var linterOptions = {
384-
eventEditor: true,
384+
editorType: 'event',
385385
};
386386
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, 'vertical', linterOptions);
387387
window.codeMirrorEditor = that.syntaxHiglighter;

‎resources/js/src/database/routines.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ const DatabaseRoutines = {
397397
*/
398398
var $elm = $('textarea[name=item_definition]').last();
399399
var linterOptions = {
400-
routineEditor: true,
400+
editorType: 'routine',
401401
};
402402
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, 'vertical', linterOptions);
403403
window.codeMirrorEditor = that.syntaxHiglighter;

‎resources/js/src/table/structure.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,15 @@ AJAX.registerOnload('table/structure.js', function () {
338338
designerModalPreviewModal.addEventListener('shown.bs.modal', () => {
339339
const modalBody = designerModalPreviewModal.querySelector('.modal-body');
340340
const $form = $('#move_column_form');
341+
const serialized = $form.serialize();
342+
if (serialized === $form.data('serialized-unmoved')) {
343+
modalBody.innerHTML = '';
344+
return;
345+
}
346+
341347
const formUrl = $form.attr('action');
342348
const sep = CommonParams.get('arg_separator');
343-
const formData = $form.serialize() +
349+
const formData = serialized +
344350
sep + 'preview_sql=1' +
345351
sep + 'ajax_request=1';
346352
$.post({

‎resources/js/src/triggers.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ const DatabaseTriggers = {
389389
*/
390390
var $elm = $('textarea[name=item_definition]').last();
391391
var linterOptions = {
392-
triggerEditor: true,
392+
editorType: 'trigger',
393393
};
394394
that.syntaxHiglighter = Functions.getSqlEditor($elm, {}, 'vertical', linterOptions);
395395
window.codeMirrorEditor = that.syntaxHiglighter;

‎src/Controllers/LintController.php‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use function header;
1717
use function is_array;
18+
use function is_string;
1819
use function json_encode;
1920
use function sprintf;
2021

@@ -23,6 +24,12 @@
2324
*/
2425
final class LintController implements InvocableController
2526
{
27+
public const EDITOR_SQL_PREFIX = [
28+
'event' => "DELIMITER $$ CREATE EVENT `a` ON SCHEDULE EVERY MINUTE DO\n",
29+
'routine' => "DELIMITER $$ CREATE PROCEDURE `a`()\n",
30+
'trigger' => "DELIMITER $$ CREATE TRIGGER `a` AFTER INSERT ON `b` FOR EACH ROW\n",
31+
];
32+
2633
public function __construct(private readonly ResponseRenderer $response)
2734
{
2835
}
@@ -36,7 +43,7 @@ public function __invoke(ServerRequest $request): Response|null
3643
/**
3744
* The SQL query to be analyzed.
3845
*
39-
* This does not need to be checked again XSS or MySQL injections because it is
46+
* This does not need to be checked against XSS or MySQL injections because it is
4047
* never executed, just parsed.
4148
*
4249
* The client, which will receive the JSON response will decode the message and
@@ -45,6 +52,23 @@ public function __invoke(ServerRequest $request): Response|null
4552
* @var string $sqlQuery
4653
*/
4754
$sqlQuery = $request->getParsedBodyParam('sql_query', '');
55+
$options = $request->getParsedBodyParam('options', []);
56+
57+
$editorType = is_array($options) ? ($options['editorType'] ?? null) : null;
58+
$prefix = is_string($editorType) ? self::EDITOR_SQL_PREFIX[$editorType] ?? '' : '';
59+
60+
$lints = Linter::lint($prefix . $sqlQuery);
61+
if ($prefix !== '') {
62+
// Adjust positions to account for prefix
63+
foreach ($lints as $i => $lint) {
64+
if ($lint['fromLine'] === 0) {
65+
continue;
66+
}
67+
68+
$lints[$i]['fromLine'] -= 1;
69+
$lints[$i]['toLine'] -= 1;
70+
}
71+
}
4872

4973
// Disabling standard response.
5074
$this->response->disable();
@@ -53,18 +77,7 @@ public function __invoke(ServerRequest $request): Response|null
5377
header(sprintf('%s: %s', $name, $value));
5478
}
5579

56-
$options = $request->getParsedBodyParam('options');
57-
if (is_array($options)) {
58-
if (! empty($options['routineEditor'])) {
59-
$sqlQuery = 'CREATE PROCEDURE `a`() ' . $sqlQuery;
60-
} elseif (! empty($options['triggerEditor'])) {
61-
$sqlQuery = 'CREATE TRIGGER `a` AFTER INSERT ON `b` FOR EACH ROW ' . $sqlQuery;
62-
} elseif (! empty($options['eventEditor'])) {
63-
$sqlQuery = 'CREATE EVENT `a` ON SCHEDULE EVERY MINUTE DO ' . $sqlQuery;
64-
}
65-
}
66-
67-
echo json_encode(Linter::lint("DELIMITER $$\n" . $sqlQuery . "$$\nDELIMITER ;\n"));
80+
echo json_encode($lints);
6881

6982
return null;
7083
}

0 commit comments

Comments
 (0)