From 3a83478fbbada796aa80dd6a3560f785c0d2fdb1 Mon Sep 17 00:00:00 2001 From: Andrei Shapiro Date: Thu, 26 Oct 2023 13:40:51 +0300 Subject: [PATCH] chore: keep original order --- core/kernel/persistence/smoothsql/class.Resource.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/kernel/persistence/smoothsql/class.Resource.php b/core/kernel/persistence/smoothsql/class.Resource.php index 750b4717a..1f0d48209 100644 --- a/core/kernel/persistence/smoothsql/class.Resource.php +++ b/core/kernel/persistence/smoothsql/class.Resource.php @@ -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;