From 25c35950e7c2eff7cb4ff3bdc39119a2bbf8e687 Mon Sep 17 00:00:00 2001
From: Axel Rutz <axel.rutz@clever-systems.net>
Date: Sat, 9 Mar 2013 04:04:20 +0100
Subject: [PATCH] Entity Issue #1937856: Added Always allow entity id for
 EntityDrupalWrapper.

---
 includes/entity.property.inc |    4 +++-
 includes/entity.wrapper.inc  |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/includes/entity.property.inc b/includes/entity.property.inc
index 48d360a..4022d41 100644
--- a/includes/entity.property.inc
+++ b/includes/entity.property.inc
@@ -251,7 +251,9 @@ function entity_property_verify_data_type($data, $type) {
       return TRUE;
     }
     elseif (isset($info[$type]['entity keys']['name'])) {
-      return entity_property_verify_data_type($data, 'token');
+      if (entity_property_verify_data_type($data, 'token')) {
+        return TRUE;
+      }
     }
     return entity_property_verify_data_type($data, empty($info[$type]['fieldable']) ? 'text' : 'integer');
   }
diff --git a/includes/entity.wrapper.inc b/includes/entity.wrapper.inc
index 4ee1c3a..c81b722 100644
--- a/includes/entity.wrapper.inc
+++ b/includes/entity.wrapper.inc
@@ -711,7 +711,7 @@ class EntityDrupalWrapper extends EntityStructureWrapper {
    */
   public function value(array $options = array()) {
     // Try loading the data via the getter callback if there is none yet.
-    if (!isset($this->data)) {
+    if (!isset($this->data) && entity_property_verify_data_type($this->id, 'token')) {
       $this->setEntity(parent::value());
     }
     if (!empty($options['identifier'])) {
-- 
1.7.9.5

