Hi,
if i create a comment in a article and click on "send", i became this errors:

Notice: Undefined index: format in _syntaxhighlighter_comment_validate() (line 274 of /Library/WebServer/Documents/drupal-7.0/sites/all/modules/syntaxhighlighter/syntaxhighlighter.module).
Notice: Undefined index: in filter_list_format() (line 675 of /Library/WebServer/Documents/drupal-7.0/modules/filter/filter.module).
Warning: Invalid argument supplied for foreach() in filter_list_format() (line 675 of /Library/WebServer/Documents/drupal-7.0/modules/filter/filter.module).
Notice: Undefined index: format in comment_submit() (line 2183 of /Library/WebServer/Documents/drupal-7.0/modules/comment/comment.module).
Status messageYour comment has been queued for review by site administrators and will be published after approval.

This happends with the plain-text-"editor". The comments was saved correctly.

Comments

mattyoung’s picture

I cannot replicate the problem. There must be something different that I didn't know about. Can you insert the following in syntaxhighlighter.module, line 273:

error_log(var_export($form_state['values'], TRUE));

the function should look like this afterward:

function _syntaxhighlighter_comment_validate($form, &$form_state) {
  error_log(var_export($form_state['values'], TRUE));
  foreach ($form_state['values']['comment_body'] as $lang => $v) {
    if (_syntaxhighlighter_format_has_syntaxhighlighter_filter($v[0]['format'])) {
      _syntaxhighlighter_validate_input("comment_body][$lang][0][value", $v[0]['value']);
    }
  }
}

Submit a comment and post the output in the php log here.

sTaX-1’s picture

This extra code do nothing.

But instead I insert

function _syntaxhighlighter_comment_validate($form, &$form_state) {
var_dump($form_state['values']);
exit();
  foreach ($form_state['values']['comment_body'] as $lang => $v) {
    if (_syntaxhighlighter_format_has_syntaxhighlighter_filter($v[0]['format'])) {
      _syntaxhighlighter_validate_input("comment_body][$lang][0][value", $v[0]['value']);
    }
  }
}

and this shows me this:

array(20) {
["name"]=>
string(3) "Tim"
["mail"]=>
string(0) ""
["homepage"]=>
string(0) ""
["date"]=>
string(0) ""
["status"]=>
int(1)
["subject"]=>
string(0) ""
["is_anonymous"]=>
bool(false)
["cid"]=>
NULL
["pid"]=>
NULL
["nid"]=>
string(2) "15"
["language"]=>
string(3) "und"
["uid"]=>
int(0)
["node_type"]=>
string(20) "comment_node_article"
["submit"]=>
string(9) "Speichern"
["preview"]=>
string(8) "Vorschau"
["comment_body"]=>
array(1) {
["und"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(4) "test"
}
}
}
["form_build_id"]=>
string(48) "form-ph9aqtBOzwx8WJmiXUUYcM6UjAe1Pds_-9mCE0CzXHg"
["form_token"]=>
string(43) "w3HsvYRBpUzV0PyQltUtwaEGJP_QjexU6pc6KMXZj4g"
["form_id"]=>
string(25) "comment_node_article_form"
["op"]=>
string(9) "Speichern"
}

The syntax highlighting filter isn't activated for plaintext...

Another thing is:
If I allow "filtered html" with the ckeditor, than filtered and plain text works without problems.

Sorry for my bad English. German is my native language but I hope you unterstand what I mean.

sTaX-1’s picture

It seems that this is not syntaxhighlighter bug but a comment module bug.
http://drupal.org/node/813052

mattyoung’s picture

Hm...so you don't have the "format" value on your side. You have this:

["comment_body"]=>
array(1) {
["und"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(4) "test"
}
}
}

But I have this:

  'comment_body' => 
  array (
    'und' => 
    array (
      0 => 
      array (
        'value' => 'Yuck',
        'format' => 'plain_text',
      ),
    ),
  ),

Do you have the "Text format" dropdown right below the "Comment" textarea? That's part of the comment form and that is where the "format" value is from.

mattyoung’s picture

>It seems that this is not syntaxhighlighter bug but a comment module bug.
>http://drupal.org/node/813052

I see. I'll follow that issue and see what to do.

Thanks!

mattyoung’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Needs review

I added code to check for the format key not exist when "Plain text" text processing is turn on. It's checke into HEAD. Can you test the 'dev' version?

sTaX-1’s picture

I applied the patch by hand and now all seems to work. Alle errors are gone.

Thanks for your help.

Edit: This patch: http://drupal.org/files/issues/comment_89.patch

mattyoung’s picture

Title: Validing comments » Validating comments
Version: 7.x-1.x-dev » 7.x-1.1
Status: Needs review » Closed (fixed)
bryancasler’s picture

I was getting a similar notice without this module. The patch in #7 worked to correct it. Where did the patch in #7 come from, is this something that is going to be committed to core?