Skip to content

Commit

Permalink
PR fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Oct 19, 2023
1 parent d6490ce commit 76568ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/RecursiveStagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ protected function getOwnedIdentifiers(DataObject $object, string $stage): array
*/
protected function getOwnedObjects(DataObject $object): array
{
/** @var DataObject|Versioned $object */
if (!$object->hasExtension(RecursivePublishable::class)) {
return [];
}
Expand All @@ -137,8 +138,10 @@ protected function getOwnedObjects(DataObject $object): array

if (!array_key_exists($cacheKey, $this->ownedObjectsCache)) {
$this->ownedObjectsCache[$cacheKey] = $object
// We intentionally avoid recursive traversal here as it's not memory efficient,
// stack based approach is used instead for better performance
// We intentionally avoid "true" recursive traversal here as it's not performant
// (often the cause of memory usage spikes and longer exeuction time due to deeper stack depth)
// Instead we use "stack based" recursive traversal approach for better performance
// which avoids the nested method calls
->findOwned(false)
->toArray();
}
Expand Down

0 comments on commit 76568ac

Please sign in to comment.