Add a comment and only apply caching if using the standard NumChildrenMethod

This commit is contained in:
Maxime Rainville 2018-10-01 11:29:51 +13:00
parent 77339b7e75
commit 13c89d0ed0
1 changed files with 7 additions and 1 deletions

View File

@ -454,7 +454,13 @@ class TreeDropdownField extends FormField
$obj = null;
$sourceObject = $this->getSourceObject();
Hierarchy::prepopulate_numchildren_cache($sourceObject);
// Precache numChildren count if possible.
if ($this->getNumChildrenMethod() == 'numChildren') {
// We're not calling `Hierarchy::prepopulateTreeDataCache()` because we're not customising results based
// on version or Fluent locales. So there would be no performance gain from additional caching.
Hierarchy::prepopulate_numchildren_cache($sourceObject);
}
if ($id && !$request->requestVar('forceFullTree')) {
$obj = DataObject::get_by_id($sourceObject, $id);
$isSubTree = true;