The validate method in OgBehaviorHandler has:

$errors = array();

at the end, which I guess is designed to remove normal field errors for the og field as the error handling is done differently. However $errors is passed by reference from entityreference_field_validate() and contains all the existing errors for the entity. So as far as I can tell this is removing all existing errors for all fields. The impact depends on when this field validate is run, but I've had this prevent field validation for a particular field on my site.

I've fixed this by changing it to unset any existing errors for that individual field, which seems to fix the issue, and OG errors still seem to work correctly.

Comments

richard.thomas’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new514 bytes

Here is the one line patch.

shushu’s picture

Status: Needs review » Needs work
StatusFileSize
new616 bytes

Thanks for the fix.
I just added a comment to clarify the change.
Can you provide a test for the validation, showing an error from another field still exist ?

amitaibu’s picture

Status: Needs work » Fixed

Committed, thanks.

joachim’s picture

Could we have a new release with this fix please? I'd have considered this a critical, as it can cause bad data to get into a system because other fields' validation errors are killed off.

I also see a sort of follow-up here:

    if ($new_errors) {
      og_field_widget_register_errors($field_name, $new_errors);
    }

This method can be called from field_attach_validate(), which is completely out of the flow of anything to do with widgets. Filed #2217129: OgBehaviorHandler::validate() fails to register errors correctly, and should not assume there's a widget.

amitaibu’s picture

> Could we have a new release with this fix please?

Yes, I'm planning to do one hopefully this week.

amitaibu’s picture

2.6 will be out soon.
https://drupal.org/node/2219385

Status: Fixed » Closed (fixed)

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