Under some circumstances, an entity is not fully loaded, and will not be fully loaded due to caching.

Without going into too much detail, I have a node with a field for user references. This field is protected by field permissions.

When a person posts a comment to the node, an email needs to be sent to the users referenced by the field. However, if the user posting the comment does not have access to the field contents, then the emails are not sent.

In other words, the user reference info is not loaded as part of the "comment:node" entity object. If the action "Fetch entity by id" is run using "comment:node:nid" as the argument, the field is *still* not loaded, because the entity is already cached without the field info.

We probably need an option to choose whether or not to to load the entity from cache or an option to clear the entity cache, but I'm not sure which is preferable.

CommentFileSizeAuthor
#1 load_entity_with_refresh-1565848-01.patch665 bytescoreyp_1
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

coreyp_1’s picture

Component: Rules Core » Rules Engine
FileSize
665 bytes

For the record, I *know* that this is not the best approach, but I am on a deadline, and I had to have a quick solution.

This patch basically forces the "Fetch entity by id" action to perform the load while resetting the cache.

eliaspallanzani’s picture

Component: Rules Engine » Rules Core

maybe this is related.
i have an antity B with a entityreference field.
When i save an entity A, i want open the entity B in edit mode and set the reference field with a value from an entity A field.
Now, i make a rule that after save A load the entity B by id.
But i cannot access the field of entity B to set value.
And i cannot set a condition "entity B has field" because this condition will be tested when i save the entity A.

p.s. if you create *a new* entity B and force saving, you can edit the field of the new entity with the same rule.

andrea.failli’s picture

Hi,
I'm having the same issue. The patch by coreyp_1 seems to work fine :).
Thank you!