From 2f444ead345aa5825cd161cde6e6c44a2b654a59 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Oct 2022 18:31:51 +1300 Subject: [PATCH] Revert "Review revert unrelated change" This reverts commit bf064fa5c96f5d0dc260ee50ff9c32622696f47d. --- app/controllers/api/databases.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 414bec3c4a..8df90b8fcf 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -1752,15 +1752,14 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') $indexes = $collection->getAttribute('indexes'); // Search for index - $indexIndex = array_search($key, array_column($indexes, 'key')); + $indexIndex = array_search($key, array_map(fn($idx) => $idx['key'], $indexes)); if ($indexIndex === false) { throw new Exception(Exception::INDEX_NOT_FOUND); } - $index = new Document([\array_merge($indexes[$indexIndex], [ - 'collectionId' => $database->getInternalId() . '_' . $collectionId, - ])]); + $index = $indexes[$indexIndex]; + $index->setAttribute('collectionId', $database->getInternalId() . '_' . $collectionId); $response->dynamic($index, Response::MODEL_INDEX); });