mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8409 from open-sausages/pulls/4/treedropdown-caching
MINOR Add caching to the TreeDropdownField tree action
This commit is contained in:
commit
755907d117
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user