Problem/Motivation
Was reviewing the template_preprocess_comment() function's code and noticed a bug. The parent comment author was being built off the wrong comment.
if ($comment->pid->target_id) {
// Fetch and store the parent comment information for use in templates.
$comment_parent = $comment->pid->entity;
$account_parent = comment_prepare_author($comment);
$variables['parent_comment'] = $comment_parent;
$variables['parent_author'] = theme('username', array('account' => $account_parent));
Proposed resolution
comment_prepare_author($comment);
should be
comment_prepare_author($comment_parent);
Related Issues
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | commentparentbefore1.png | 48.99 KB | andymartha |
| #4 | commentparentafter1.png | 62.02 KB | andymartha |
| #2 | commentparentafter1.png | 73.26 KB | andymartha |
| #1 | 1990732-1-comment-parent.patch | 780 bytes | joelpittet |
Comments
Comment #1
joelpittetComment #2
andymartha commentedAfter applying patch 1990732-1-comment-parent.patch in #1 by joelpittet on a fresh Drupal 8 install, I detect that nothing broke and Drupal comments seem to function as normal through adding, viewing, and using them in Views.

Comment #3
joelpittet@andymartha thanks for having a look, should have posted manual testing instructions...
So this patch fixes the new hidden HTML element holding a parent comment in nested comments for accessibility reasons.
Steps to reproduce(should have wrote these before):
It should show the current author as the parent and the child author without the patch and different with the patch.
Hope that helps
Comment #4
andymartha commentedOK, I get it now. After applying patch 1990732-1-comment-parent.patch in #1 by joelpittet on a fresh Drupal 8 install, I detect that the patch changed the author from the original. See screenshots.
Before
Comment 1
-- Comment 2 replies to 1
-- Comment 3 replies to 2 (attributed to replies to 1)
After
Comment 1
-- Comment 2 replies to 1
-- Comment 3 replies to 2 (attributed to replies to 2)
Comment #5
joelpittetWicked @andymartha! Thanks a lot for the review, that's the ticket!
Comment #6
alexpottCommitted b466d93 and pushed to 8.x. Thanks!