When I try to comment with anonymous user, the comment is missing and sometimes it has this error:

Notice: Undefined variable: key in comment_prepare_thread() (line 901 of /www/examplesite/test1/root/modules/comment/comment.module).
EntityMalformedException: Missing bundle property on entity of type comment. in entity_extract_ids() (line 7633 of /www/examplesite/test1/root/includes/common.inc).

The permissions for View comments, Post comments and Skip comment approval are activated for anonymous users..
In the phpAdmin on table comment I can see all the comments and uid is 0.

This problem doesn't occur when is commented with admin account.

Comments

satvision83’s picture

Finally I found the answer for this.
Somehow the user with UID 0 that usually is created from the Drupal Core has been deleted, so I've created a new user in Drupal, and edited in phpAdmin the table users. I edit all the fields from the fresh created user into like this: uid 0, created 0, access 0, login 0, status 0 and picture 0. All other fields should be empty.
I hope this will help someone.

darcylicious’s picture

Thank you for this. I don't know how it happened, but 2 of my sites had this issue. Thanks for figuring it out!