Upgrading from 7.x-1.11 to 7.x-1.12 seems to have introduced this unwanted behaviour. I'm not sure if this is a PHP version issue or what, but the following line (244) seems to evaluate as true for my non-collection field:

      if (isset($value['value']['value'])) { // Field collections have them nested.

My $value is technically a single-level array at this point (e.g. array('value' => 'DE')). Unfortunately PHP is treating the 'value' string as an array for the purposes of isset(), so isset($value['value']['value']) evaluates as true (and $value['value']['value'] returns the first character of the string).

This can easily be fixed by restoring the is_array($value['value']) checks from 7.x-1.11. I've taken this a bit further and streamlined the logic (all the Field Collection checks can be inside a single is_array() check, and I've added an is_array($value) wrapper around all the $value[*] checks because I'm pretty sure the same issue would crop up with a $value['value'] check against a string $value).

CommentFileSizeAuthor
string-as-array.patch3.57 KBkingandy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kingandy created an issue. See original summary.

kingandy’s picture

Status: Active » Needs review

I guess this should be Needs Review since there's a patch.

NWOM’s picture

Version: 7.x-1.12 » 7.x-1.x-dev
Status: Needs review » Needs work

This no longer applies to the newest dev or stable. It appears to need a reroll, however maybe it is no longer needed either.