Closed (duplicate)
Project:
Drupal core
Version:
7.0
Component:
comment.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Jan 2011 at 22:47 UTC
Updated:
16 Jan 2020 at 15:45 UTC
Jump to comment: Most recent
Comments
Comment #1
bfroehle commentedDuplicate of #1020658: Notice: Undefined property: stdClass::$comment_count in comment_node_page_additions() (line 724 of /....
Comment #2
scottrouse commentedThanks. Neither Google or D.O's search found that for me.
Comment #3
bfroehle commentedI found it by searching for 'comment_count' on the Drupal project issue page. http://drupal.org/project/issues/drupal?text=comment_count :)
Hope you can figure out a solution for the bug.
Comment #4
manumazu commentedHello, it happens when node_comment_statistics table is empty. I had this problem after adding content directly in node content : the trigger that is counting comments is disable.
You can verify if this table is empty or not, or a relation between nid in node table and nid in node_comment_statistics is not broken.
This query works fine :
INSERT INTO `node_comment_statistics` (`nid`, `cid`, `last_comment_timestamp`, `last_comment_name`, `last_comment_uid`, `comment_count`)
SELECT nid, 0, UNIX_TIMESTAMP(), NULL, 1, 0 FROM node
Hope it can help you ...
Comment #5
kosmik commentedI too was manually uploading contents into drupal 7 tables from drupal 6. Everything seemed to work ok except I was seeing a similar error notice as you guys.
After many many trials, I noticed I have to fully populate table "node_comment_statistics" for "comment_count" even for those without comments. Just enter node id and "0" for comment count for all nodes with no comments.
Hope this helps!
Comment #6
amirtaiar commentedI have been trying to followup but didn't really understand what to do.
Can you be more detailed please?
Thank you!
Comment #7
xcel commentedThe query given by manumazu worked fine for me.
Thanks a lot !
Comment #8
davidwhthomas commentedThis SQL query will also rebuild comment statistics and fixes the error, in Drupal 7
Credit: http://drupal.org/node/137458
HTH.
DT
Comment #9
franklca commentedThe SQL query in comment #8 works like magic! Thank you for posting.
Comment #10
johnnydarkko commented#8 was perfect for me. Thanks @davidwhthomas!
Comment #11
W.M. commented@davidwhthomas
Thanks very much.. solved 2 issues for me
Comment #12
akki123 commented#8 worked like charm.
Thanks
Comment #13
betarobot commentedDavid, thank you so much! Was totally puzzled, but #8 worked for me perfectly as well.
Comment #14
Zanel commented#8 works for me, but only temporarily.
I find that I have to apply it at least daily...
Is there a permanent fix? What could be causing this error to repeatedly occur? Failing that, can this be put into a PHP file (PHP NOOB here) that can be called by cron?
Thanks!
Comment #15
tohidd commentedThank you for sql query on comment 8. it saved my ass
Comment #16
revez2002 commentedThis issue had me scratching my head, but after running the SQL query posted by davidwhthomas (comment#8), everything is working like a charm.
Thanks David!
Comment #17
func0der commentedPlease, be aware that the query from comment#8 does NOT save last commentator of a node correctly.
To fix such issues simply run the cron manually via the backend or drush cron via the terminal.
That should fix this issue, too, and update the last commentator of the nodes.
Comment #18
libbyy commentedI tried running the cron but I still get the following error:
Notice: Undefined property: stdClass::$comment_count in comment_node_page_additions() (line 728 of /usr/www/users/XXX/extranet/modules/comment/comment.module).
can anyone advise?
Comment #19
drupixI had the same problem with a custom module who create custom node.
After changing the weight of my module to "1" (higer than comment.module) the problem disapear for new custom content created.
To resolve the problem for custom nodes created before I change the weight of my modules, I had to use the script #8.
Now, everything works fine.
Comment #20
func0der commentedSince there is no proper way to set the weight of a module from installation on, I would say that A solution, but not THE solution for the cause of the problem.
Comment #21
electrokate commented#8 query still working wonders, thanks!
Comment #22
jorisx commentedJust ran in the same weird error..
But #8 Fixed it! Many thanks!!!
Comment #23
maikeru commented#8 won't for those using postgres, instead replace ifnull with coalesce.
Comment #24
oduranvdavidwhthomas's solution works for me. Thanks.
Regards.
Comment #25
ElZipo commentedI just disable comment module... I'll replace facebook comment or disqus comment
Comment #26
blogers commented#8 works for me, orfanat nodes missed in table node_comment_statistics, with #8 fixed all table thanks
Comment #27
shomari commentedStill an issue today and #8 worked like a charm.
Comment #28
vchen commented#8 still works.
For anyone needing extra instructions, you can run the entire SQL query with
drush sqlc. Wait until you see the mysql> prompt, then copy and paste the entire SQL query and hit enter. Get out of mysql by typingexit.Also, running this did not delete my comments.
UPDATE: This actually didn't work on the server (php 7.3.11). I did notice that this happens primarily on unpublished pages while logged in, at least from my experience. This notice did not pop up when logged out. It had worked for my local instance on php 7.3.9.