diff --git a/entity.module b/entity.module
index 0f552a3..1dd719a 100644
--- a/entity.module
+++ b/entity.module
@@ -861,8 +861,12 @@ function template_preprocess_entity(&$variables) {
   else {
     // Else, try to automatically detect it.
     $uri = entity_uri($entity_type, $entity);
-    $variables['url'] = $uri ? url($uri['path'], $uri['options']) : FALSE;
-    $variables['page'] = $uri && $uri['path'] == $_GET['q'];
+    
+    $variables['url'] = $uri && isset($uri['path']) ? url($uri['path'], $uri['options']) : FALSE;
+    
+    if (isset($uri['path'])) {
+      $variables['page'] = $uri && $uri['path'] == $_GET['q'];
+    }
   }
 
   // Helpful $content variable for templates.
