function relation_save($relation) {
  try {
    field_attach_validate('relation', $relation);
  }
  catch (FieldValidationException $e) {
   // ??? message
    return FALSE;
  }
...

Comments

toolin’s picture

This seems to me a pretty significant issue - a validation error causes relation_save() to silently fail.

There may be other plans for validation, but for now simply re-throwing the exception would be an improvement.

For anyone who encounters this, a FieldValidationException has an attribute errors, an array of error codes and messages. So to see what went wrong look at $e->errors . You need to hack the code in relation.module to re-throw the exception like this:

...
function relation_save($relation) {
  try {
    field_attach_validate('relation', $relation);
  }
  catch (FieldValidationException $e) {
    throw $e; // HACK HACK HACK
    return FALSE;
  }
...
matglas86’s picture

This bug is mentioned here #1395092: Relation fields not getting saved and here #1350588: relation_endpoint_field_validate() should also check if entity is_new when testing if the relation is unique. The last issue is visually affected by it. This needs to be fixed for experience use at least. Maybe just a drupal_set_message() to mention what went wrong.

mikran’s picture

Component: Code » API
Status: Active » Needs review
StatusFileSize
new472 bytes

The attached patch adds watchdog error.

Status: Needs review » Needs work

The last submitted patch, field_validation_error-1362304-3.patch, failed testing.

mikran’s picture

Status: Needs work » Needs review
StatusFileSize
new473 bytes

typo.

mikran’s picture

Status: Needs review » Fixed

Patch committed

Status: Fixed » Closed (fixed)

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

aaronbauman’s picture

Status: Closed (fixed) » Active

So, now we're successfully logging that an exception occurred, but not actually logging the exception message.

aaronbauman’s picture

Status: Active » Closed (fixed)

Nevermind, I see the exception message is no more descriptive either.