If a node doesn't have any comments, we know this without doing a full pager query to find out.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Good catch catch.

Dries’s picture

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

I committed this to CVS HEAD. I believe it should go into DRUPAL-6 but I'll leave that up to Gabor so he can review it once more. Updated the version accordingly. It might need a re-roll for Drupal 6 ...

catch’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.24 KB

Thanks. Re-roll for 6.

catch’s picture

Version: 6.x-dev » 7.x-dev
Priority: Normal » Critical
FileSize
662 bytes

This broke comment approval tests - if a node only has one comment, and that comment is unpublished, we no longer render it. We could probably find a way around this like a separate 'has comments' flag to the count one, but for now here's a straight revert. I miss the test bot :(

Dries’s picture

Status: Needs review » Needs work

Rolled back the patch.

catch’s picture

Priority: Critical » Normal
Status: Needs work » Needs review
FileSize
1.95 KB

Thanks Dries.

This gets more interesting.

I fixed the first bug with a user_access('administer comments') check.

However, I then found that the comment 'approve' link bypasses comment_save (as does everything in http://api.drupal.org/api/function/comment_operations/6) - this means that node_comment_statistics never gets updated - so the tests still have one fail without that being fixed.

Also, when manually testing the comment approval, I noticed that the published/unpublished radios are mislabeled. Fun.

So, here's a new patch which both adds the proper checks to avoid the query, and fixes comment_approve() so that tests continue to pass, this bug was hidden due to the lack of the $node->comment_status check but is now covered by the comment approval test.

I've opened issues for the other two bugs at #352911: comment administration form mis-labeling and #352895: comment_operations bypasses comment_save.

comment_save() should also take a properly formatted comment object instead of a fapi array, but there must be an issue for that somewhere already.

catch’s picture

FileSize
2.23 KB

Better code comment.

moshe weitzman’s picture

Welcome to dark dark world of comment module.

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Needs review
catch’s picture

Issue tags: +Performance
moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

thanks, comment module maintainer :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
2.06 KB

re-rolled due to a whitespace change. No changes, so leaving RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD, thanks! :)

Status: Fixed » Closed (fixed)
Issue tags: -Performance

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