Problem/Motivation
We're concerned here with the route comment.reply
and the method \Drupal\comment\Controller\CommentController::getReplyForm()
.
Currently, comment module does some gymanstics to get a fully-rendered node and just a single comment on a page.
// The comment is in response to a entity.
elseif ($entity->access('view', $account)) {
// We make sure the field value isn't set so we don't end up with a
// redirect loop.
$entity->{$field_name}->status = CommentItemInterface::HIDDEN;
// Render array of the entity full view mode.
$build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, 'full');
unset($build['commented_entity']['#cache']);
$entity->{$field_name}->status = $status;
}
Note the hiding of the comment field, rendering the node, then reseting of the comment field status. This is not ideal, especially because we're actively unsetting the cache property, so this page becomes uncached.
Proposed resolution
What we might try instead is for the Comment module to provide a node view mode that is a combo of the fully-rendered entity and the comment form. Or, in the case of a reply to a comment, the comment being replied to and a comment form -- this last case might require a view mode for comment as well.
We could then cache the entity/comment reply pages given the unique view mode.
User interface changes
None.
API changes
None.