Skip to content

Commit

Permalink
FIX: Use Hierarchy::prepopulate_numchildren_cache in tree-generation
Browse files Browse the repository at this point in the history
Only relevant if silverstripe/silverstripe-framework#8380 is avialable,
however coded defensively so it can be merged before that PR if needs 
be.

See silverstripe/silverstripe-framework#8379
  • Loading branch information
Sam Minnee committed Sep 21, 2018
1 parent 6e7bc38 commit 95fae36
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\HiddenClass;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\Hierarchy\MarkedSet;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\ValidationResult;
Expand Down Expand Up @@ -493,6 +494,11 @@ 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);
}

$html = $this->getSiteTreeFor($this->config()->get('tree_class'));

$this->extend('updateSiteTreeAsUL', $html);
Expand Down

0 comments on commit 95fae36

Please sign in to comment.