In the function _form_validate the value of $elements['#value'] is an array of sometimes.
If the value is passed as an array, then also passed an array in the function drupal_strlen (form.inc line 691), that results in an error:

mb_strlen() expects parameter 1 to be string, array given in .../drupal/includes/unicode.inc on line 404.

I suggest to add a check of value type in function _form_validate.
Below is a patch.

Comments

vgoodvin’s picture

Version: 6.22 » 7.x-dev
StatusFileSize
new1.27 KB

Same patch for D7.

chx’s picture

Priority: Major » Normal
Status: Active » Needs work

In general, we are accepting now checks to avoid teapot error messages like #1283892: Let Render API fail in a tale-telling way on invalid $element but this needs a test and a better explanation because this does not sound such kind of error.

rosk0’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 KB

Fixed patch.

gbirch’s picture

Issue summary: View changes

The patch should also check that the value is a string so as to prevent deprecation notices when NULL is passed to mb_strlen() by drupal_strlen().

poker10’s picture

Status: Needs review » Closed (works as designed)

I would say that the problem mentioned in the IS can happen only if there is a field with #maxlength attribute, which expects an array (for example the select form element). However according to the Form API documentation, #maxlength is only allowed on these elements: machine_name, password, textfield. I do not think either of them could have a value of array. Therefore this is likely a programming error, which is not something the Drupal 7 core should sanitize.

I am closing this as Works as designed. If someone can provide steps to reproduce which will work on the clean D7 install according to the Form API docs, then feel free to reopen this. Thanks!