Merge pull request #8409 from open-sausages/pulls/4/treedropdown-caching

MINOR Add caching to the TreeDropdownField tree action
This commit is contained in:
Maxime Rainville 2018-10-01 13:56:21 +13:00 committed by GitHub
commit 755907d117
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -453,6 +453,14 @@ class TreeDropdownField extends FormField
/** @var DataObject|Hierarchy $obj */
$obj = null;
$sourceObject = $this->getSourceObject();
// 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;