Skip to content

Commit

Permalink
Fix numerical keys
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Feb 12, 2022
1 parent 3443891 commit 50303cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Expand Up @@ -68,7 +68,7 @@ public function __invoke(): void
*/
if (isset($_POST['change_all_tables_collations']) && $_POST['change_all_tables_collations'] === 'on') {
[$tables] = Util::getDbInfo($db, '');
foreach ($tables as $tableName => $data) {
foreach ($tables as ['Name' => $tableName]) {
if ($this->dbi->getTable($db, $tableName)->isView()) {
// Skip views, we can not change the collation of a view.
// issue #15283
Expand Down
22 changes: 10 additions & 12 deletions libraries/classes/Util.php
Expand Up @@ -2271,18 +2271,16 @@ public static function getDbInfo($db, string $subPart)
}
}

$tables = array_merge(
$groupTable,
$dbi->getTablesFull(
$db,
$groupWithSeparator !== false ? $groupWithSeparator : '',
$groupWithSeparator !== false,
$limitOffset,
$limitCount,
$sort,
$sortOrder,
$tableType
)
// We must use union operator here instead of array_merge to preserve numerical keys
$tables = $groupTable + $dbi->getTablesFull(
$db,
$groupWithSeparator !== false ? $groupWithSeparator : '',
$groupWithSeparator !== false,
$limitOffset,
$limitCount,
$sort,
$sortOrder,
$tableType
);
}

Expand Down
9 changes: 4 additions & 5 deletions psalm-baseline.xml
Expand Up @@ -1262,16 +1262,15 @@
<MixedArgumentTypeCoercion occurrences="1">
<code>['db' =&gt; $db]</code>
</MixedArgumentTypeCoercion>
<MixedAssignment occurrences="2">
<code>$data</code>
<MixedArrayAccess occurrences="1">
<code>$tableName</code>
</MixedArrayAccess>
<MixedAssignment occurrences="1">
<code>['Name' =&gt; $tableName]</code>
</MixedAssignment>
<PossiblyNullArgument occurrences="1">
<code>$_POST['db_collation']</code>
</PossiblyNullArgument>
<UnusedForeachValue occurrences="1">
<code>$data</code>
</UnusedForeachValue>
</file>
<file src="libraries/classes/Controllers/Database/OperationsController.php">
<MixedArgument occurrences="10">
Expand Down

0 comments on commit 50303cd

Please sign in to comment.