mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENH Cache $item->ID for eager loading
This commit is contained in:
parent
0c40cc9b3d
commit
ed07303703
@ -928,6 +928,8 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
||||
|
||||
private function setDataObjectEagerLoadedData(DataObject $item): void
|
||||
{
|
||||
// cache $item->ID at the top of this method to reduce calls to ViewableData::__get()
|
||||
$itemID = $item->ID;
|
||||
foreach (array_keys($this->eagerLoadedData) as $eagerLoadRelation) {
|
||||
list($dataClasses, $relations) = $this->getEagerLoadVariables($eagerLoadRelation);
|
||||
$dataClass = $dataClasses[count($dataClasses) - 2];
|
||||
@ -935,7 +937,7 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
||||
foreach (array_keys($this->eagerLoadedData[$eagerLoadRelation]) as $eagerLoadID) {
|
||||
$eagerLoadedData = $this->eagerLoadedData[$eagerLoadRelation][$eagerLoadID][$relation];
|
||||
if ($dataClass === $dataClasses[0]) {
|
||||
if ($eagerLoadID === $item->ID) {
|
||||
if ($eagerLoadID === $itemID) {
|
||||
$item->setEagerLoadedData($relation, $eagerLoadedData);
|
||||
}
|
||||
} elseif ($dataClass === $dataClasses[1]) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user