Skip to content

Commit 10d3138

Browse files
Merge pull request #17376 from kamil-tekiela/getDbInfo-mangles-tables-with-numerical-names
getDbInfo mangles table with numerical names
2 parents e1b9fcd + 50303cd commit 10d3138

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

libraries/classes/Controllers/Database/Operations/CollationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __invoke(): void
6868
*/
6969
if (isset($_POST['change_all_tables_collations']) && $_POST['change_all_tables_collations'] === 'on') {
7070
[$tables] = Util::getDbInfo($db, '');
71-
foreach ($tables as $tableName => $data) {
71+
foreach ($tables as ['Name' => $tableName]) {
7272
if ($this->dbi->getTable($db, $tableName)->isView()) {
7373
// Skip views, we can not change the collation of a view.
7474
// issue #15283

libraries/classes/Util.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,18 +2271,16 @@ public static function getDbInfo($db, string $subPart)
22712271
}
22722272
}
22732273

2274-
$tables = array_merge(
2275-
$groupTable,
2276-
$dbi->getTablesFull(
2277-
$db,
2278-
$groupWithSeparator !== false ? $groupWithSeparator : '',
2279-
$groupWithSeparator !== false,
2280-
$limitOffset,
2281-
$limitCount,
2282-
$sort,
2283-
$sortOrder,
2284-
$tableType
2285-
)
2274+
// We must use union operator here instead of array_merge to preserve numerical keys
2275+
$tables = $groupTable + $dbi->getTablesFull(
2276+
$db,
2277+
$groupWithSeparator !== false ? $groupWithSeparator : '',
2278+
$groupWithSeparator !== false,
2279+
$limitOffset,
2280+
$limitCount,
2281+
$sort,
2282+
$sortOrder,
2283+
$tableType
22862284
);
22872285
}
22882286

psalm-baseline.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,16 +1229,15 @@
12291229
<MixedArgumentTypeCoercion occurrences="1">
12301230
<code>['db' =&gt; $db]</code>
12311231
</MixedArgumentTypeCoercion>
1232-
<MixedAssignment occurrences="2">
1233-
<code>$data</code>
1232+
<MixedArrayAccess occurrences="1">
12341233
<code>$tableName</code>
1234+
</MixedArrayAccess>
1235+
<MixedAssignment occurrences="1">
1236+
<code>['Name' =&gt; $tableName]</code>
12351237
</MixedAssignment>
12361238
<PossiblyNullArgument occurrences="1">
12371239
<code>$_POST['db_collation']</code>
12381240
</PossiblyNullArgument>
1239-
<UnusedForeachValue occurrences="1">
1240-
<code>$data</code>
1241-
</UnusedForeachValue>
12421241
</file>
12431242
<file src="libraries/classes/Controllers/Database/OperationsController.php">
12441243
<MixedArgument occurrences="10">

0 commit comments

Comments
 (0)