Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Use Hierarchy::prepopulate_numchildren_cache in tree-generation #2266

Merged
merged 3 commits into from
Sep 25, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be consistent here and use $this->config()->get('tree_class') to decide what we are caching.

Copy link
Member Author

@sminnee sminnee Sep 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would make sense. singleton($this->config()->get('tree_class')) most likely?

'childrenMethod' => $filter ? $filter->getChildrenMethod() : 'AllChildrenIncludingDeleted',
'numChildrenMethod' => $filter ? $filter->getNumChildrenMethod() : 'numChildren',
]);

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

Expand Down