Comments were not displaying for anonymous users with the "View comments" permission checked. Looks like this is due to line 141 of commentsblock.module which pre-maturely checks if the user has the 'post comments' permission. Instead, this can be moved to the if for display_option 0.

Won't this allow anonymous users without permission to see comments? Thankfully no, because the permission is checked by the comment_node_page_additions function itself as it should be.

Comments

marcoka’s picture

i lost track why we check for
$node->comment > 1

sokrplare’s picture

Do you know if this will get committed into a new version? Just don't want to lose changes in a site update. Thanks!

marcoka’s picture

i will commit this no worries.

sokrplare’s picture

Uh-oh - I was mistaken. Just realized $node->comment isn't the number of comments, it is the value for "whether comments can be added, read, or accessed, for this node." (source http://drupal.org/node/345297)

It still is a bug, but this means the patch in the original issue is not right.

marcoka’s picture

so this patch posted here is not correct?

sokrplare’s picture

Something like this might be more accurate (and easier to remember by using the constants):

        // Display comments and form
        if ($node->comment == COMMENT_NODE_OPEN) {
          $block['subject'] = t('Post new comment');
          
          // Only display the form if user is allowed to post
          if ($display_option == 0 && user_access('post comments')) {
            //load only the form
            $block['content'] = drupal_get_form("comment_node_{$node->type}_form", (object)array('nid' => $node->nid));
          }
          else {
            //load form along with all comments
            $block['content'] = comment_node_page_additions($node);
          }
        }
        // Display comments without form
        else if ($node->comment == COMMENT_NODE_CLOSED) {
          // load all comments (function checks if it should include form)
          $block['content'] = comment_node_page_additions($node);
        }

Probably a better way to format/structure, but I'm too tired to come up with it right now :)

geekglue’s picture

I'm experiencing the same problem so I assume this didn't go any further. The logic from the first patch seemed correct so I tried changing :

if (user_access('post comments') && $node->comment > 1) {
    //...
}

to :

if (user_access('access comments') && $node->comment > 1) {
    //...
}

This is working for me.

marcoka’s picture

thx for testing. i will add this in the next release.

sokrplare’s picture

Any chance a new release is forthcoming?

marcoka’s picture

so you tested #6 and its working? so RTBC

sokrplare’s picture

Status: Needs review » Reviewed & tested by the community

Yes, using it on two large live sites so I sure hope so! :)

marcoka’s picture

ok great. i am adding #6, wrote it to my note for tonight/tomorrow

marcoka’s picture

Status: Reviewed & tested by the community » Fixed

#6 commited to 7.x-1.4

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.