diff --git a/src/Forms/TreeDropdownField.php b/src/Forms/TreeDropdownField.php index 97df4b679..56954f415 100644 --- a/src/Forms/TreeDropdownField.php +++ b/src/Forms/TreeDropdownField.php @@ -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;