Resetting an entity_load cache bin in Drupal 7 can have more drastic consequences than in previous versions of Drupal, as we can have persistent load caches in place of the PHP static memory cache.

Instead, wherever possible, only flush the necessary entities from the cache, using entity_get_controller($entity_type)->resetCache(array($entity_id));

In this case, webform_node_update() can use entity_load_unchanged() to re-generate the specific node in question, without wiping out the entire node load cache.


jweowu’s picture

Status:Active» Needs review
new653 bytes
quicksketch’s picture

Status:Needs review» Fixed
new655 bytes

Actually I think a safer/faster way of handling this yet is just to use $node->original if it exists, since in D7 this variable is pre-populated for you already in calls to node_update.

For reference, the original call was added in #1009226: The roles allowed to access a webform don't get saved to the database correctly, in which I don't think either james.elliott or I knew about this property at that time.

quicksketch’s picture

Title:Don't use $reset flag with node_load()» Increase efficiency of hook_node_update() by using $node->original
jweowu’s picture

Ah, yes indeed. node_save() populates that using entity_load_unchanged(), so that's definitely the sensible solution.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary:View changes

Cross-referencing with core API issue