Permalink
Browse files

perf(river): no longer needlessly render river responses

For river items that cannot receive comments, we explicitly pass a `responses`
option to the river layout, which bypasses the bulk of river/elements/responses
rendering. Notably a `countComments()` query is no longer performed and an empty
form is no longer rendered for each of these items.

For BC, the `div.elgg-river-responses` wrapper is still created, but contains only
whitespace.

In the river/elements/responses view, we also now correctly check for comments
(and their subclasses like ElggDiscussionReply) so we don't render these. The
core river views do not reach to this point due to changes in this PR, so this
is mainly for plugins that may have overridden those views.

Fixes #9046
  • Loading branch information...
mrclay committed Oct 22, 2015
1 parent e0ed8cf commit 97df230f4c496d773e50060bf84fef5ae7052b24
@@ -13,4 +13,7 @@
echo elgg_view('river/elements/layout', array(
'item' => $item,
'message' => $excerpt,
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));
@@ -5,4 +5,7 @@
echo elgg_view('river/elements/layout', array(
'item' => $vars['item'],
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));
@@ -31,4 +31,7 @@
'item' => $item,
'message' => $excerpt,
'summary' => $summary,
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));
@@ -10,17 +10,16 @@
$responses = elgg_extract('responses', $vars, false);
if ($responses) {
echo $responses;
- return true;
+ return;
}
$item = $vars['item'];
/* @var ElggRiverItem $item */
$object = $item->getObjectEntity();
-$target = $item->getTargetEntity();
// annotations and comments do not have responses
-if ($item->annotation_id != 0 || !$object || elgg_instanceof($target, 'object', 'comment')) {
- return true;
+if ($item->annotation_id != 0 || !$object || $object instanceof ElggComment) {
+ return;
}
$comment_count = $object->countComments();
@@ -37,4 +37,7 @@
'item' => $vars['item'],
'message' => elgg_get_excerpt($comment->description),
'summary' => $summary,
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));
@@ -14,4 +14,7 @@
echo elgg_view('river/elements/layout', array(
'item' => $item,
'attachments' => $subject_icon . elgg_view_icon('arrow-right') . $object_icon,
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));
@@ -24,4 +24,7 @@
'use_hover' => false,
'use_link' => false,
)),
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));
@@ -20,4 +20,7 @@
echo elgg_view('river/elements/layout', array(
'item' => $item,
'summary' => $string,
+
+ // truthy value to bypass responses rendering
+ 'responses' => ' ',
));

0 comments on commit 97df230

Please sign in to comment.