Skip to content

Commit 49a8eb1

Browse files
Merge pull request #18975 from kamil-tekiela/checkResult
Remove checkResult() method
2 parents b53d63c + d42f84d commit 49a8eb1

4 files changed

Lines changed: 24 additions & 59 deletions

File tree

phpstan-baseline.neon

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6597,7 +6597,7 @@ parameters:
65976597

65986598
-
65996599
message: "#^Cannot access an offset on mixed\\.$#"
6600-
count: 6
6600+
count: 7
66016601
path: src/Database/Events.php
66026602

66036603
-
@@ -6636,12 +6636,12 @@ parameters:
66366636
path: src/Database/Events.php
66376637

66386638
-
6639-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
6639+
message: "#^Parameter \\#1 \\$string of function htmlspecialchars expects string, string\\|null given\\.$#"
66406640
count: 1
66416641
path: src/Database/Events.php
66426642

66436643
-
6644-
message: "#^Parameter \\#2 \\$errors of method PhpMyAdmin\\\\Database\\\\Events\\:\\:checkResult\\(\\) expects array, mixed given\\.$#"
6644+
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
66456645
count: 1
66466646
path: src/Database/Events.php
66476647

@@ -15157,7 +15157,7 @@ parameters:
1515715157

1515815158
-
1515915159
message: "#^Cannot access an offset on mixed\\.$#"
15160-
count: 6
15160+
count: 7
1516115161
path: src/Triggers/Triggers.php
1516215162

1516315163
-
@@ -15195,11 +15195,6 @@ parameters:
1519515195
count: 1
1519615196
path: src/Triggers/Triggers.php
1519715197

15198-
-
15199-
message: "#^Parameter \\#2 \\$errors of method PhpMyAdmin\\\\Triggers\\\\Triggers\\:\\:checkResult\\(\\) expects array, mixed given\\.$#"
15200-
count: 1
15201-
path: src/Triggers/Triggers.php
15202-
1520315198
-
1520415199
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
1520515200
count: 1

psalm-baseline.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,9 +4770,6 @@
47704770
<code><![CDATA[$GLOBALS['errors']]]></code>
47714771
<code><![CDATA[$GLOBALS['errors']]]></code>
47724772
</InvalidArrayOffset>
4773-
<MixedArgument>
4774-
<code><![CDATA[$GLOBALS['errors']]]></code>
4775-
</MixedArgument>
47764773
<MixedArrayAssignment>
47774774
<code><![CDATA[$GLOBALS['errors'][]]]></code>
47784775
<code><![CDATA[$GLOBALS['errors'][]]]></code>
@@ -4783,6 +4780,7 @@
47834780
<code><![CDATA[$GLOBALS['errors'][]]]></code>
47844781
<code><![CDATA[$GLOBALS['errors'][]]]></code>
47854782
<code><![CDATA[$GLOBALS['errors'][]]]></code>
4783+
<code><![CDATA[$GLOBALS['errors'][]]]></code>
47864784
</MixedArrayAssignment>
47874785
<MixedAssignment>
47884786
<code><![CDATA[$GLOBALS['errors']]]></code>
@@ -12111,9 +12109,6 @@
1211112109
<code><![CDATA[$GLOBALS['errors']]]></code>
1211212110
<code><![CDATA[$GLOBALS['errors']]]></code>
1211312111
</InvalidArrayOffset>
12114-
<MixedArgument>
12115-
<code><![CDATA[$GLOBALS['errors']]]></code>
12116-
</MixedArgument>
1211712112
<MixedArrayAssignment>
1211812113
<code><![CDATA[$GLOBALS['errors'][]]]></code>
1211912114
<code><![CDATA[$GLOBALS['errors'][]]]></code>
@@ -12124,6 +12119,7 @@
1212412119
<code><![CDATA[$GLOBALS['errors'][]]]></code>
1212512120
<code><![CDATA[$GLOBALS['errors'][]]]></code>
1212612121
<code><![CDATA[$GLOBALS['errors'][]]]></code>
12122+
<code><![CDATA[$GLOBALS['errors'][]]]></code>
1212712123
</MixedArrayAssignment>
1212812124
<MixedAssignment>
1212912125
<code><![CDATA[$GLOBALS['errors']]]></code>

src/Database/Events.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,15 @@ public function handleEditor(): string
105105
// the new one. Try to restore the backup query
106106
$result = $this->dbi->tryQuery($createItem);
107107
if (! $result) {
108-
$GLOBALS['errors'] = $this->checkResult($createItem, $GLOBALS['errors']);
108+
// OMG, this is really bad! We dropped the query,
109+
// failed to create a new one
110+
// and now even the backup query does not execute!
111+
// This should not happen, but we better handle
112+
// this just in case.
113+
$GLOBALS['errors'][] = __('Sorry, we failed to restore the dropped event.') . '<br>'
114+
. __('The backed up query was:')
115+
. '"' . htmlspecialchars($createItem) . '"<br>'
116+
. __('MySQL said: ') . $this->dbi->getError();
109117
}
110118
} else {
111119
$GLOBALS['message'] = Message::success(
@@ -335,27 +343,6 @@ public function getEventSchedulerStatus(): bool
335343
return strtoupper($state) === 'ON' || $state === '1';
336344
}
337345

338-
/**
339-
* @param string|null $createStatement Query
340-
* @param mixed[] $errors Errors
341-
*
342-
* @return mixed[]
343-
*/
344-
private function checkResult(string|null $createStatement, array $errors): array
345-
{
346-
// OMG, this is really bad! We dropped the query,
347-
// failed to create a new one
348-
// and now even the backup query does not execute!
349-
// This should not happen, but we better handle
350-
// this just in case.
351-
$errors[] = __('Sorry, we failed to restore the dropped event.') . '<br>'
352-
. __('The backed up query was:')
353-
. '"' . htmlspecialchars((string) $createStatement) . '"<br>'
354-
. __('MySQL said: ') . $this->dbi->getError();
355-
356-
return $errors;
357-
}
358-
359346
/**
360347
* Returns details about the EVENTs for a specific database.
361348
*

src/Triggers/Triggers.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ public function handleEditor(): string
9999
$result = $this->dbi->tryQuery($createItem);
100100

101101
if (! $result) {
102-
$GLOBALS['errors'] = $this->checkResult($createItem, $GLOBALS['errors']);
102+
// OMG, this is really bad! We dropped the query,
103+
// failed to create a new one
104+
// and now even the backup query does not execute!
105+
// This should not happen, but we better handle
106+
// this just in case.
107+
$GLOBALS['errors'][] = __('Sorry, we failed to restore the dropped trigger.') . '<br>'
108+
. __('The backed up query was:')
109+
. '"' . htmlspecialchars($createItem) . '"<br>'
110+
. __('MySQL said: ') . $this->dbi->getError();
103111
}
104112
} else {
105113
$GLOBALS['message'] = Message::success(
@@ -224,27 +232,6 @@ public function getQueryFromRequest(): string
224232
return $query;
225233
}
226234

227-
/**
228-
* @param string $createStatement Query
229-
* @param mixed[] $errors Errors
230-
*
231-
* @return mixed[]
232-
*/
233-
private function checkResult(string $createStatement, array $errors): array
234-
{
235-
// OMG, this is really bad! We dropped the query,
236-
// failed to create a new one
237-
// and now even the backup query does not execute!
238-
// This should not happen, but we better handle
239-
// this just in case.
240-
$errors[] = __('Sorry, we failed to restore the dropped trigger.') . '<br>'
241-
. __('The backed up query was:')
242-
. '"' . htmlspecialchars($createStatement) . '"<br>'
243-
. __('MySQL said: ') . $this->dbi->getError();
244-
245-
return $errors;
246-
}
247-
248235
/**
249236
* Returns details about the TRIGGERs for a specific table or database.
250237
*

0 commit comments

Comments
 (0)