I've tried Unique Field 7.x-1.0-beta1, in a Drupal 7 installation, with default language set to Spanish.

On editing nodes, the following messages are registered on watchdog, and Unique Field won't detected repeated values:

Warning: Invalid argument supplied for foreach() en unique_field_node_validate() (línea 168 de /var/www/drupal/sites/default/modules/unique_field/unique_field.module).

Warning: array_values() expects parameter 1 to be array, null given en _field_filter_items() (línea 494 de /var/www/drupal/modules/field/field.module).

The problem seems to be in these lines:

166          $f = $node->$field;
167          $values = $f[LANGUAGE_NONE];
168          foreach ($values as $index => $value) {
                [..]
             }

In my installation, the $f variable is indexed with the 'es' language code:

array(1) {
  ["es"]=> array(1) { [0]=> array(1) { ["email"]=> string(22) "yyyyyy@gmail.com" } } 
}

So, the $f[LANGUAGE_NONE] (aka $f['und']) element is undefined, the field content is in $f['es'] instead.

See Field Language API

Thank you in advance, for your help.

CommentFileSizeAuthor
#2 unique_field-1037904-2.patch621 bytesboobaa

Comments

mcotelo’s picture

Title: Invalid argument supplied for foreach() in unique_field_node_validate(), line 168 » Default language set to spanish: Invalid argument supplied for foreach() in unique_field_node_validate(), line 168
boobaa’s picture

Status: Active » Needs review
StatusFileSize
new621 bytes

Met the same warnings. Attached patch seems to solve the issue.

arithmetric’s picture

Title: Default language set to spanish: Invalid argument supplied for foreach() in unique_field_node_validate(), line 168 » Incompatible with localized/translated content
Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Needs review » Fixed

Thanks for this report and patch. I've fixed this bug in the latest release (7.x-1.0-beta2).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.