Skip to content

Commit

Permalink
chore: keep original order
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed Oct 26, 2023
1 parent bcffb67 commit 3a83478
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/kernel/persistence/smoothsql/class.Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ public function getClassesResourceIds(array $classIds): array
$results = $statement->fetchAll();
$resourceIds = [];

foreach ($results as $result) {
$resourceId = $result['subject'];
$classId = $result['object'];
$resourceIds[$classId] = $resourceIds[$classId] ?? [];
$resourceIds[$classId][] = $resourceId;
// Iterate over the provided class IDs to keep the same order
foreach ($classIds as $classId) {
$resources = array_filter($results, static fn (array $result): bool => $result['object'] === $classId);
$resourceIds[$classId] = array_column($resources, 'subject');
}

return $resourceIds;
Expand Down

0 comments on commit 3a83478

Please sign in to comment.