When an entity is exported in a feature, it is being casted as an object which works fine for non-Entity classed entities (node etc), but can cause issue for Entity classed ones (field collections). During import entity_save is eventually called for the object, but since the object is not of the right class, the right save method is not called.
The following code is in place that does that conversion and according to the author the reason is entity_import will try to save the object to the DB immediately. https://www.drupal.org/node/1429604#comment-5566480
+ // Convert entities to array to avoid having them in JSON returned from standard implementation of $entity->export().
+ if (is_object($entity) && method_exists($entity, 'export')) {
+ $entity = get_object_vars($entity);
+ }
However that appears to be incorrect or at least out-dated now. entity_import does not try and save the entity and using entity_export & entity_import should be preferred over type casting all entities to stdClass.
Attached patch just removes that code so features_var_export can export the Entity object properly.
Comment | File | Size | Author |
---|---|---|---|
#8 | uuid-entity-class-export-2776429-8.patch | 717 bytes | sarvab |
Comments
Comment #2
sarvab CreditAttribution: sarvab commentedComment #7
skwashd CreditAttribution: skwashd at Dave Hall Consulting for Pfizer, Inc. commented@sarvab is this patch generated against current HEAD of the 7.x-1.x branch?
Comment #8
sarvab CreditAttribution: sarvab commentedNo it wasn't, sorry about that.
Here is an updated patch.
Comment #9
skwashd CreditAttribution: skwashd at Dave Hall Consulting for Pfizer, Inc. commentedLet's see what the bot thinks of the change...