Currently, field_attach_update() is called first during file_entity_file_update(). This needs to happen actually after hook_file_update() so that fields will be passed the file entity after it has been saved to the database.
This matters for file_entity_revisions when saving a revision, because the vid passed to the fields hasn't yet been updated with the next vid. This causes the most recent field revision to be overridden with the new data, and the resulting revision_id is one behind where it should be for the corresponding file.
This comes about from #2098007: Field revisioning isnt working quite right.
Comment | File | Size | Author |
---|---|---|---|
#1 | file_entity-hook_entity_update-2103195-1.patch | 1.02 KB | reubenavery |
Comments
Comment #1
reubenavery CreditAttribution: reubenavery commentedMy proposed solution is to move the field_attach_update() call into an implementation of hook_entity_update() which is invoked immediately following hook_file_update by file_save().
Here's my little patch.
Comment #2
klonos...coming from #2098007: Field revisioning isnt working quite right.
Comment #3
Dave ReidInvoking field_attach_update as soon as possible is the standard behavior. That's what node_save() does - it invokes field_attach_insert/update before hook_node_insert/update and hook_entity_insert/update.
Comment #4
reubenavery CreditAttribution: reubenavery commentedhmm.. but it also invokes field_attach_presave() first, which file_save does not.
quite a series of rabbit holes, this process.
Comment #4.0
reubenavery CreditAttribution: reubenavery commentedAdding link to file_entity_revisions issue which started this.