diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index fa0ab3a81e..2f0048c131 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -491,13 +491,11 @@ public function LinkPreview() */ public function SiteTreeAsUL() { - // Pre-cache sitetree version numbers for querying efficiency - Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::DRAFT); - Versioned::prepopulate_versionnumber_cache(SiteTree::class, Versioned::LIVE); - - if (method_exists(Hierarchy::class, 'prepopulate_numchildren_cache')) { - Hierarchy::prepopulate_numchildren_cache(SiteTree::class, Versioned::DRAFT); - } + $filter = $this->getSearchFilter(); + SiteTree::singleton()->prepopulateTreeDataCache(null, [ + 'childrenMethod' => $filter ? $filter->getChildrenMethod() : 'AllChildrenIncludingDeleted', + 'numChildrenMethod' => $filter ? $filter->getNumChildrenMethod() : 'numChildren', + ]); $html = $this->getSiteTreeFor($this->config()->get('tree_class'));