I have a simple clone of drupal.org's issue queues on a D7 site, and since there's already the issue information fields, I wanted to set the comment body (as well as title) fields as not required.
This works all right, but whenever you only set any of the issue fields and leave both title and body blank, the following error appears:
Notice: Undefined offset: 0 in comment_submit() (line 2183 of /home/web/anticto/drupal-dev/modules/comment/comment.module).
Notice: Undefined offset: 0 in comment_submit() (line 2183 of /home/web/anticto/drupal-dev/modules/comment/comment.module).
That's caused by direct access to the field value, which could be wrapped with an isset check:
2183: $comment->subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment->comment_body[LANGUAGE_NONE][0]['value'], $comment->comment_body[LANGUAGE_NONE][0]['format'])))), 29, TRUE);
Comments
Comment #1
lyricnz commentedI can reproduce. Patch attached.
Comment #2
lyricnz commentedCNR
Comment #3
dixon_I believe this applies to 8.x too.
Comment #4
dixon_After reading this more in detail I realized that this seems to be a duplicate of #1038652: Notices in comment_submit() and comment_admin_overview() when body field does not exist or is not required. That issue has some more discussion and a more complete patch.