If an entity has already been loaded,
entity_load() retrieves it from memory rather than reloading it. Makes sense.
But: what can you do when you need to reload an entity that has already been loaded - when the entity's data has (or, may have) been changed in the database since it was loaded by another function, and you need the changed version?
The closest I can find to a way to reload an entity is to call
entity_load() with the 4th parameter of
entity_load() to true - for example,
entity_load( $entity_type, $entity_id, null, true ); - however, this does much more than just reload the entity.
It also appears to reset the cache on the server, which can have a lot of undesired side effects (for example, I'm finding that calling this as a step in the process of saving an entity causes a cache to be created for the entity's fields that is missing field data, and this faulty created cache persists even as the entity is saved, causing it to seem like the entity's fields failed to save and a blank entity was saved, at least until caches are cleared). From googling around, I get the impression that setting this parameter is generally considered to be A Bad Idea (posts I've seen aren't specific about why, but my experience offers a clue).
So, how can I re-load an entity that has already been loaded but which I suspect has been changed since being loaded, with minimal other consequences?
Drupal 7, and while core-based answers are best any answers that use the Entity API contrib module or other robust contrib modules are fine.