Skip to content

Commit de1c9a9

Browse files
committed
Fix migration logic from cache to result map
1 parent bd4db0a commit de1c9a9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/SelectTree.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ private function buildTreeFromResults($results, $parent = null): Collection
216216
$resultCache[$resultKey]['in_set'] = 1;
217217
// Move any cached children to the result map
218218
if(isset($resultCache[$resultKey]['children'])){
219-
$resultMap[$resultKey] = array_merge($resultMap[$resultKey], $resultCache[$resultKey]['children']);
219+
// Since the result map won't have a key for a given result until it's confirmed to be in the set (i.e. this very moment),
220+
// we don't have to preserve the previous value for that key; it is guaranteed to have been unset
221+
$resultMap[$resultKey] = $resultCache[$resultKey]['children'];
220222
unset($resultCache[$resultKey]['children']);
221223
}
222224
$parentKey = $result->{$this->getParentAttribute()};

0 commit comments

Comments
 (0)