Skip to content

Commit

Permalink
perf(river): no longer needlessly render river responses
Browse files Browse the repository at this point in the history
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 Elgg#9046
  • Loading branch information
mrclay committed Oct 22, 2015
1 parent e0ed8cf commit 47e0272
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions mod/groups/views/default/river/group/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
echo elgg_view('river/elements/layout', array(
'item' => $item,
'message' => $excerpt,
'responses' => ' ',
));
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

echo elgg_view('river/elements/layout', array(
'item' => $vars['item'],
'responses' => ' ',
));
1 change: 1 addition & 0 deletions mod/thewire/views/default/river/object/thewire/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
'item' => $item,
'message' => $excerpt,
'summary' => $summary,
'responses' => ' ',
));
7 changes: 3 additions & 4 deletions views/default/river/elements/responses.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions views/default/river/object/comment/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
'item' => $vars['item'],
'message' => elgg_get_excerpt($comment->description),
'summary' => $summary,
'responses' => ' ',
));
1 change: 1 addition & 0 deletions views/default/river/relationship/friend/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
echo elgg_view('river/elements/layout', array(
'item' => $item,
'attachments' => $subject_icon . elgg_view_icon('arrow-right') . $object_icon,
'responses' => ' ',
));
1 change: 1 addition & 0 deletions views/default/river/user/default/profileiconupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
'use_hover' => false,
'use_link' => false,
)),
'responses' => ' ',
));
1 change: 1 addition & 0 deletions views/default/river/user/default/profileupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
echo elgg_view('river/elements/layout', array(
'item' => $item,
'summary' => $string,
'responses' => ' ',
));

0 comments on commit 47e0272

Please sign in to comment.