First I would like to thank all developers of this great module for their efforts!

I experimented with entity reference in conjunction with workbench moderation.
When I attach an entity reference field to a moderated node, and make a reference to a node, it works out all fine.

However, if I reference to an entity - in my test to a file entity – the reference gets lost when the moderated node is made public.
It stays referenced between all states before publishing.

Looking at the database tables, the reference is recorded at "field_revision_field_reference" but never finds its way to "field_data_field_reference".

I wonder, if the revision and its associated data are deleted before the data of all fields are processed to the published version of the node.

If someone could give me a hint,
I'll take a shot at the code to look where this is happening.

Thanks
Stefan

Comments

bmx269’s picture

I am having a issue with an entity reference "product reference" field as well. This is related. Any updates?

tedbow’s picture

I also have problem with Compatibility with Entity Reference but I think it is different issue.

I am trying to have an entity reference to a node that is being moderated and doesn't have a published version yet.

This will not work b/c in Entity Reference:

/**
 * Override for the Node type.
 *
 * This only exists to workaround core bugs.
 */
class EntityReference_SelectionHandler_Generic_node extends EntityReference_SelectionHandler_Generic {
  public function entityFieldQueryAlter(SelectQueryInterface $query) {
    // Adding the 'node_access' tag is sadly insufficient for nodes: core
    // requires us to also know about the concept of 'published' and
    // 'unpublished'. We need to do that as long as there are no access control
    // modules in use on the site. As long as one access control module is there,
    // it is supposed to handle this check.
    if (!user_access('bypass node access') && !count(module_implements('node_grants'))) {
      $base_table = $this->ensureBaseTable($query);
      $query->condition("$base_table.status", NODE_PUBLISHED);
    }
  }
}

The current user doesn't have 'bypass node access' permission and this module doesn't implements 'node_grants'.
So this force to only allow referencing to published nodes. The current can see the node b/c they have 'view all unpublished content' permission from this module.

Not sure what a fix would be.

UPDATE:
Solved my problem by using a View to control which Nodes should be able to be referenced.
I forgot about that. See #1253776: Add views support for providing a list of entities or bundles (views filtering, relationships, etc)

yuriy.babenko’s picture

Experiencing the same issue.