Commit de44cb8c authored by webchick's avatar webchick
Browse files

Issue #1827582 by dawehner: Load all nodes of comments at once.

parent 015d61bc
......@@ -32,9 +32,18 @@ public function buildContent(array $entities = array(), $view_mode = 'full', $la
parent::buildContent($entities, $view_mode, $langcode);
// Load all nodes of all comments at once.
$nids = array();
foreach ($entities as $entity) {
$node = node_load($entity->nid);
if (!$node) {
$nids[$entity->nid] = $entity->nid;
}
$nodes = node_load_multiple($nids);
foreach ($entities as $entity) {
if (isset($nodes[$entity->nid])) {
$node = $nodes[$entity->nid];
}
else {
throw new \InvalidArgumentException(t('Invalid node for comment.'));
}
$entity->content['#node'] = $node;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment