0

I deleted the comment body from the content type settings, and replaced it with another field. When posting comments, I get this error:

Notice: Undefined property: stdClass::$comment_body in function comment_submit() (line 2201 in file /modules/comment/comment.module).

Can this error be avoided?

It was needed to delete the field comment_body becase field permissions are inherited for all the content types and that is why another field was created and this one was deleted.

4
  • Yes, despite the comment body is a field that can be removed from the UI, the Comment module assume the field is always present.
    – apaderno
    May 3 '16 at 4:07
  • Oh, it is a little bit confusing. Can it be fixed in any way? May 3 '16 at 4:12
  • Did you try making a field with same machine name and type?
    – Dev
    May 3 '16 at 5:57
  • In this case I need to delete the field comment_body becase field permissions are inherited for all the content types and that is why I created another field and deleted this one. Yes, if I add it back, it is restored but this action doesn't completely solve the problem. May 3 '16 at 11:33
2
  • Create a random content type
  • Restore the comment_body field from existing field`s, because it's existing now
  • Delete the random content type
3
  • I need to delete the field comment_body becase field permissions are inherited for all the content types and that is why I created another field and deleted this one Aug 9 '16 at 22:52
  • You can turn off required option on the field comment_body and hide via css. Another solution drupal.org/node/1038652#comment-10968421
    – TaraZingo
    Aug 10 '16 at 20:53
  • I tried to do the same but with 'author' and 'subject' fields but non of them are in the 'Select an existing field' list. Any ideas? Nov 26 '19 at 3:42
1

There is also a patch which actually needs review in Drupal Core concerning this issue: https://www.drupal.org/node/2717717

I applied it and it works.

0

First delete that field and clean Drupal's Cache, if that doesn't work just try to use this patch:

https://www.drupal.org/files/issues/1038652-comment-body-field-95-test-and-fix-D7.patch

1
  • I need to delete the field comment_body becase field permissions are inherited for all the content types and that is why I created another field and deleted this one Aug 9 '16 at 22:52
0

I recovered comments with recreating the tables (take care: all the comments will be removed):

  • comment,
  • field_data_comment_body,
  • field_revision_comment_body;

and reset statistics with:

UPDATE node_comment_statistics SET comment_count = 0;

Where to get SQL query to recreate them? Get it from another Drupal installation with comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.