Ref: http://drupal.org/node/1020658
I dont want to get scolded for simply trying to find an answer to an issue so I post this here instead of opening old wounds :)
On a WAMP server this error suddenly cropped up for a New content type I added "Instruction Manuals". I have numerous custom/added content-types on this install but when adding an article to this newest content type, instruction-manuals, this error crops up on node-view but not on teaser listings.
Notice: Undefined property: stdClass::$comment_count in comment_node_page_additions() (line 721 of C:\~\drupalvanilla\public\modules\comment\comment.module).
I initially set up the instruction-manuals with comments disabled. When I created the first "instruction-manual" the error below cropped up, but only for that content type and only in full node view. I enabled comments for it to see if that fixed it. No. I added a comment to see if that fixed it. No, but comments work fine in teasers/listings (action links etc) and my new comment shows up in node view along with its "reply" link etc and the Add Comment form also appears nicely.
I cite http://drupal.org/node/1020658 as a reference. Before upgrading to D7.2 (today) the error notice declared line 724 of comment.module. It changed to line 721 after upgrading. I understand why the line number would change the point is the error starting-point has not changed.
My other content-types use the exact same structure as "instruction-manuals" the only difference is the "term-reference" used in each content typed. Each content type uses its own taxonomy vocabulary but other than that I have not introduced any new modules or changed anything aside from todays upgrade to 7.2
Changing line 721 fixed the error however in the post that I cite it mentions in #7 the flow of the functions. Based on that I really dont see how the error is cropping up and cannnot find significant difference in my new content type from the others. They all use taxonomy vocabularies but so what, the structure is the same on the new content type. So while this "fixes" the error, I dont think the error should be thrown at all.
Lines 718 - 723:
// Only attempt to render comments if the node has visible comments.
// Unpublished comments are not included in $node->comment_count, so show
// comments unconditionally if the user is an administrator.
//if (($node->comment_count && user_access('access comments')) || user_access('administer comments')) {
// BUG - see http://drupal.org/node/1020658
if ((!empty($node->comment_count) && user_access('access comments')) || user_access('administer comments')) {
As I said, my content types are nearly identical aside from taxonomy. I am at a loss for direction and am out of ideas on where to look for anwsers.
Comments
Comment #1
bryancasler commentedWe hired someone to do a D6 -> D7 migration and now that same error is cropping up. They say it's not related to the migration work they did. I just want it fixed.
Drupal 7.0
*different line number as OP mentioned
Comment #2
manumazu commentedHello, this happens when a relation is broken between node table and node_comment_statistics : if the property comment_count is not returned this is because the row is not found, the bug appears.
You have to add comment_count values (or 0) in node_comment_statistics table for each nodes that display this error.
Hope it can help you.
Comment #3
bryancasler commentedThanks manumazu.
Comment #4
Anonymous (not verified) commentedI do have a corresponding record in node_comment_statistics table.
In #1020658: Notice: Undefined property: stdClass::$comment_count in comment_node_page_additions() (line 724 of /... it was suggested that we shouldn't use
!empty()as it is simply a coverup of a possible problem.Comment #5
sutharsan commentedI have found that the nodes which result in this error have no record in the table {node_comment_statistics}. In our case the error was found after migrating a Drupal 6 side (under development) to Drupal 7. The Drupal 6 {node_comment_statistics} had the same records as D7. The problem is already present in Drupal 6 as you can see in #345297: $node->comment_count is broken.
A quick fix is to run devel_rebuild_node_comment_statistics() as described here http://drupal.org/node/137458.