hook_field_update_forbid()
allows modules to prevent fields from being updated, but field_ui doen't catch the documented FieldUpdateForbiddenException
s when they are thrown.
I don't know enough about creating tests for the Drupal test suite to prepare a full patch, so I will provide some notes here for someone (may be at a later date) to work from.
field_ui.admin.inc:1580 Only attempts to catch FieldException
s, but not FieldUpdateForbiddenException
s. I propose that line 1585 the following code be inserted:
catch (FieldUpdateForbiddenException $e) {
drupal_set_message(t('Update of field %label forbidden: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error');
$form_state['redirect'] = field_ui_next_destination($entity_type, $bundle);
}
A more significant issue exists in field_ui.admin.inc:1974
Call to field_update_field
isn't wrapped in a try-catch block, so any exceptions thrown aren't caught. This code should be wrapped in a similar try-catch block which handles both FieldException
s, and FieldUpdateForbiddenException
s
Comments
Comment #1
q0rban CreditAttribution: q0rban commentedI see you ran into this in UUID module, but I cannot reproduce this:
This works fine for me.
Comment #2
yched CreditAttribution: yched commentedrecategorize