Download & Extend

unnecessary error reported for options validations

Project:Drupal core
Version:6.22
Component:forms system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

When options are validated, like a set of required radio buttons, an error will be logged when the user submits the form with no radio button selected.

The user gets to see the proper validation message, like "[element title] is required.", which is good.

But at the same time a watchdog error is logged: "Illegal choice [emptry string] in [element title] element.".

For the end user there is no issue here.

For the site administrator, in most cases, this just means extra noise in the watchdog list.

In some cases it can become a real problem though. If you are using a module that emails all errors, like http://drupal.org/project/logging_alerts, for example.

The fix is very easy, when checking for invalid options, first make sure the actual value is not empty. See attached patch.

Also, as a side note, the two watchdog error reports for Illegal Choices are preceded by form_error, where the user is instructed to contact the site administrator. This message never gets shown to the end user for some reason, I could not figure why. Is this because a form_error was already logged against this element?

AttachmentSizeStatusTest resultOperations
options_validation_error.patch715 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch options_validation_error.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details | Re-test

Comments

#1

Status:active» needs review

Make sense.

#2

I can see the benefit for having that error message. You should rarely see it, and in the case that it happens, it either means something is going wrong or someone is trying to hack the forms on your site. In both of those cases, I'd want to know.

I can undestand cleaning this message up a little bit, but let's not remove it.

#3

Sorry, but I cannot see any benefit for this error message.

No hacking or anything wrong must happen in order to get this condition.

#4

Version:6.6» 6.22

This issue is active on drupal.org too.

When changing this very issue project to ie Drupal Webmaster then press tab the error is produced.

  1. Click on Project: field
  2. delete core
  3. select 'Drupal.org webmasters'
  4. press enter
  5. Click on Project: field
  6. press tab
  7. Presto

I bumped this up to latest D6 assuming d.o is using that version too.

The patch looks useful but needs work as form.inc has too places this message occurs and filter module has a similar message.

includes/form.inc:              form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
includes/form.inc:          form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
modules/filter/filter.module:  form_error($form, t('An illegal choice has been detected. Please contact the site administrator.'));

#5

Status:needs review» needs work

The last submitted patch, options_validation_error.patch, failed testing.

#6

unnecessary error reported for options validations

Steps to reproduce

Running this jQuery with ie firebug

$('#edit-title').focus()
$('#edit-project-info-project-title').val('Drupal core')
$('#edit-project-info-project-title').blur()

$('#edit-project-info-project-title').val('Drupal.org webmasters')
$('#edit-title').focus()
$('#edit-project-info-project-title').blur()

[ Powered by #1115636: Issue Macros and Templates - _default]

Please fix the reported issues. Don't forget to set status to needs review when submitting a new patch.

AttachmentSizeStatusTest resultOperations
unnecessary error reported for options validations | drupal.org_.png40.09 KBIgnored: Check issue status.NoneNone