entity_metadata_wrapper does not load correct revisions

Created on 19 September 2012, about 12 years ago
Updated 27 November 2024, 7 days ago

Latest dev of entity_api and field_collection.

I have a node containing a field collection, with revisions enabled.

function mymodule_node_view($node, &$view_mode, $langcode) {
  print 'NODE<br />';
  print 'vid: ' . $node->vid . '<br />';
  foreach ($node->field_field_collection[LANGUAGE_NONE] as $key => $collection) {
    print $collection['revision_id'] . '<br />';
  }
  
  print '<br />WRAPPER<br />';
  $wrapper = entity_metadata_wrapper('node', $node);
  print 'vid: ' . $wrapper->vid->value() . '<br />';
  foreach ($wrapper->field_field_collection as $key => $collection) {
    print $collection->revision_id->value() . '<br />';
  }

  die;
}

Output:

When viewing the latest node revision:

NODE
vid: 273
255
256
257

WRAPPER
vid: 273
255
256
257

When viewing an older node revision:

NODE
vid: 271
221
222
223

WRAPPER
vid: 271
255
256
257

entity_metadata_wrapper is loading the latest revisions for the field collection, not the field collection revisions specified by the wrapped node entity.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Entity property wrapper

Created by

🇳🇿New Zealand john pitcairn

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany Elin Yordanov

    I'm using this patch almost 7 years in multiple projects. I don't think it makes any sense to block this issue, because of missing tests.

Production build 0.71.5 2024