function entity_load_unchanged

entity_load_unchanged($entity_type, $id)

Loads the unchanged, i.e. not modified, entity from the database.

Unlike entity_load() this function ensures the entity is directly loaded from the database, thus bypassing any static cache. In particular, this function is useful to determine changes by comparing the entity being saved to the stored entity.

Parameters

$entity_type: The entity type to load, e.g. node or user.

$id: The ID of the entity to load.

Return value

The unchanged entity, or FALSE if the entity cannot be loaded.

File

includes/common.inc, line 8009
Common functions that many Drupal modules will need to reference.

Code

function entity_load_unchanged($entity_type, $id) {
  entity_get_controller($entity_type)->resetCache(array($id));
  $result = entity_get_controller($entity_type)->load(array($id));
  return reset($result);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!common.inc/function/entity_load_unchanged/7.x