The following code produces unwanted markup when the user does not have permission to post comments and there are no other links:

<?php if ($links = render($content['links'])): ?>
  <nav><?php print $links; ?></nav>
<?php endif; ?>

The resulting markup is:
<nav><ul class="links inline"><li class="comment-forbidden first last"></li></ul></nav>

The following code in comment_links() causes this to happen:

 else {
  $links['comment-forbidden']['title'] = theme('comment_post_forbidden', array('node' => $node));
  $links['comment-forbidden']['html'] = TRUE;
} 

Comments

jacine’s picture

Status: Active » Needs review
StatusFileSize
new624 bytes

Not sure if this is the proper way to fix this, but here's a patch to review.

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Novice

I think there's a big meta issue somewhere about whether to use this sort of pattern when an element should be empty. Unfortunately I can't find it at the moment, though...

In any event, we'll need to reroll this now. Tagging as novice for the task of rerolling the Drupal 8.x patch.

If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.

kathyh’s picture

Status: Needs work » Needs review
StatusFileSize
new644 bytes

Re-rolled for #2 D8 /core. After botcheck - back to big meta issue discussion.

star-szr’s picture

Issue tags: +Needs tests

I'm not sure where the meta discussion is, but the patch in #3 still applies cleanly to D8 head, so tagging for tests.

ivan zugec’s picture

I can't replicate this issue on the latest 8.x-dev, looks like it's been fixed. If a user doesn't have the right permissions, they'll see the following markup:

<ul class="links inline"><li class="comment-forbidden odd first last"><span><a href="/user/login?destination=node/1%23comment-form">Log in</a> or <a href="/user/register?destination=node/1%23comment-form">register</a> to post comments</span></li></ul>

There's also a test within the assertCommentLinks() method.

Bußmeyer’s picture

StatusFileSize
new624 bytes

Just created a patch for D7 that is based on the patch #3.

Status: Needs review » Needs work

The last submitted patch, comment-forbidden-1321248-06-d7.patch, failed testing.

star-szr’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs work » Needs review

Issue needs to be set to 7.x for testing the patch in #6.

star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Novice, +Needs backport to D7

The last submitted patch, comment-forbidden-1321248-06-d7.patch, failed testing.

Bußmeyer’s picture

StatusFileSize
new624 bytes

I modified the patch for D7. There was a little typo in it.

Bußmeyer’s picture

Status: Needs work » Needs review
droplet’s picture

Version: 7.x-dev » 8.x-dev

D8 first

BrockBoland’s picture

Version: 8.x-dev » 7.x-dev

According to #5, this has been fixed in D8. The patch in #11 needs to be tested for D7, and test needs to be written.

Bojhan’s picture

Status: Needs review » Reviewed & tested by the community

Works for me, does this really need tests? Silly issue.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Well if we already have tests for D8 (as indicated in #5), we should get 'em backported to D7.

diego21’s picture

Assigned: Unassigned » diego21
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.51 KB

I did this patch using Drupal 8 assertComentLinks() as source, as was said in #16. I don't know if it's correct or how test it in Drupal 7. Can someone tell me how can I do it? Thanks in advance!

Status: Needs review » Needs work

The last submitted patch, 17: assertCommentLinks_d8_backported_to_d7-1321248-17.patch, failed testing.

diego21’s picture

Trying again :D.

diego21’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: assertCommentLinks_d8_backported_to_d7-1321248-19.patch, failed testing.

diego21’s picture

Anyone could tell me how can I test this patch? Thanks! :D

dercheffe’s picture

Hello @all,
I have exactly the same problem in my Drupal-installation (Drupal 7.41).
If a user is not logged in, the node links do not appear like in the bug description mentioned. The normal behaviour of a fresh core installation is, that there appears a message "please log in or register to post a comment". This message is unfortunately missing in my drupal. If the user is logged in, then all node links are shown correctly. Is there already a solution of the problem?

To adjust my settings more precise, I use the module "field permission". Maybe there be a bug too?

Best whises,
Phil

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.