During my research on which field-hooks can manipulate the item data I've found that there seems to be no guarantee that hook_field_presave() is ever called. The responsibility to call field_attach_presave() lies with the module that implements the entity type.
Also field_attach_presave() is not executed at all for default values from the instance settings. This practically makes hook_presave() effectively useless.
Attached is a patch that moves the calls to field_attach_insert() from the entity implementations to field_attach_insert() and field_attach_update().
This seems to be the root-cause for problems like #1140188: Incorrect integer value: 'autocreate' for column 'tid' (default values for autocomplete widgets are not autocreated) .
Attachment | Size | Status | Test result | Operations |
---|---|---|---|---|
field_guarantee_hook_field_presave.patch | 2.23 KB | Idle | PASSED: [[SimpleTest]]: [MySQL] 40,349 pass(es). | View details | Re-test |