From 5540dadaafbbd3ec7504a4ad2bcec621976a181e Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Thu, 8 Dec 2022 18:08:59 +0000 Subject: [PATCH] Added fix to allow nested AutoDatasource instances to manage their own populateCache --- modules/cms/classes/AutoDatasource.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/cms/classes/AutoDatasource.php b/modules/cms/classes/AutoDatasource.php index b0fc39fa5..c554b2f9e 100644 --- a/modules/cms/classes/AutoDatasource.php +++ b/modules/cms/classes/AutoDatasource.php @@ -68,6 +68,14 @@ class AutoDatasource extends Datasource implements DatasourceInterface $this->postProcessor = new Processor; } + /** + * Returns the in memory path cache map + */ + public function getPathCache(): array + { + return $this->pathCache; + } + /** * Populate the local cache of paths available in each datasource * @@ -78,6 +86,13 @@ class AutoDatasource extends Datasource implements DatasourceInterface { $pathCache = []; foreach ($this->datasources as $datasource) { + // Allow AutoDatasource instances to handle their own internal caching + if ($datasource instanceof AutoDatasource) { + $datasource->populateCache($refresh); + $pathCache[] = array_merge(...array_reverse($datasource->getPathCache())); + continue; + } + // Remove any existing cache data if ($refresh && $this->allowCacheRefreshes) { Cache::forget($datasource->getPathsCacheKey());