views_bulk_operations_queue_item_process() calls _views_bulk_operations_entity_load() and then loops over the returned objects, modifying and saving each one.
The problem is that it's possible for the act of saving an entity to trigger updates to other entities (one example of this is node synchronisation across the nodes in a translation set); and therefore it's possible that the object originally loaded by VBO is out-dated by the time it tries to modify and save it.
The fix is easy -- simply call entity_load() again inside the loop before processing each entity. In the normal case where the entity has not been modified in the interim, this additional entity_load will pull the object directly from the entity load cache, with no performance impact.
If specific revisions are being loaded, we do not need to re-load them, as they will not (can not) have changed.
The following is purely for searchability: the particular issue I encountered involved a combination of VBO, i18n_sync, and workbench_moderation causing the publish/unpublish vbo actions to fail. Specifically, the $node->workbench_moderation_state_new property checked for by workbench_moderation_node_presave() will be TRUE for the translation node when it gets processed by VBO (if the translation was already saved by a sync), and that presave function consequently modifies (again) the publication state, contrary to the user's request.
With the patch, this problem does not occur.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | views_bulk_operations-entity_load-2057591-1.patch | 1.1 KB | jweowu |
Comments
Comment #1
jweowu commentedComment #2
bojanz commentedThanks for the explanation. The fix sounds reasonable. I'll try to commit it soon.
Comment #2.0
bojanz commentedDetailed the instance of the bug which I encountered
Comment #3
bojanz commentedTweaked and committed: http://drupalcode.org/project/views_bulk_operations.git/commit/636e461