Index: modules/field/modules/field_sql_storage/field_sql_storage.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module,v
retrieving revision 1.48
diff -u -r1.48 field_sql_storage.module
--- modules/field/modules/field_sql_storage/field_sql_storage.module	26 Jun 2010 02:16:23 -0000	1.48
+++ modules/field/modules/field_sql_storage/field_sql_storage.module	21 Jul 2010 16:10:18 -0000
@@ -546,7 +546,8 @@
   if (isset($query->deleted)) {
     $select_query->condition("$field_base_table.deleted", (int) $query->deleted);
   }
-  if ($query->propertyConditions || $query->propertyOrder) {
+
+  if ($query->propertyConditions || $query->propertyOrder || $query->tags) {
     if (empty($query->entityConditions['entity_type']['value'])) {
       throw new EntityFieldQueryException('Property conditions and orders must have an entity type defined.');
     }
Index: includes/entity.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/entity.inc,v
retrieving revision 1.11
diff -u -r1.11 entity.inc
--- includes/entity.inc	7 Jul 2010 13:13:44 -0000	1.11
+++ includes/entity.inc	21 Jul 2010 16:10:18 -0000
@@ -323,6 +323,11 @@
  * specified or if the query has field conditions or sorts that are stored in
  * different field storage engines. However, this logic can be overridden in
  * hook_entity_query().
+ *
+ * Also note that this query does not automatically respect entity access
+ * restrictions. If you are querying for entities in order to display them to
+ * a user, you can to use EntityFieldQuery::addTag() in order to add the proper
+ * access restrictions to your query.
  */
 class EntityFieldQuery {
   /**
@@ -434,6 +439,15 @@
   public $age = FIELD_LOAD_CURRENT;
 
   /**
+   * A list of the tags added to this query.
+   *
+   * @var array
+   *
+   * @see EntityFieldQuery::addTag()
+   */
+  public $tags = array();
+
+  /**
    * The ordered results.
    *
    * @var array
@@ -735,6 +749,31 @@
   }
 
   /**
+   * Adds a tag to the query.
+   *
+   * Tags are strings that mark a query so that hook_query_alter() and
+   * hook_query_TAG_alter() implementations may decide if they wish to alter
+   * the query. A query may have any number of tags, and they must be valid PHP
+   * identifiers (composed of letters, numbers, and underscores). For example,
+   * queries involving nodes that will be displayed for a user need to add the
+   * tag 'node_access', so that the node module can add access restrictions to
+   * the query.
+   *
+   * If an entity field query has tags, it must also have an entity type
+   * specified, because the alter hook will need the entity base table.
+   *
+   * @param string $tag
+   *   The tag to add.
+   *
+   * @return EntityFieldQuery
+   *   The called object.
+   */
+  public function addTag($tag) {
+    $this->tags[] = $tag;
+    return $this;
+  }
+
+  /**
    * Executes the query.
    *
    * After executing the query, $this->orderedResults will contain a list of
@@ -889,7 +928,7 @@
   /**
    * Finishes the query.
    *
-   * Adds the range and returns the requested list.
+   * Adds tags and range; returns the requested list or count.
    *
    * @param SelectQuery $select_query
    *   A SelectQuery which has entity_type, entity_id, revision_id and bundle
@@ -901,6 +940,9 @@
    *   See EntityFieldQuery::execute().
    */
   function finishQuery($select_query, $id_key = 'entity_id') {
+    foreach ($this->tags as $tag) {
+      $select_query->addTag($tag);
+    }
     if ($this->range) {
       $select_query->range($this->range['start'], $this->range['length']);
     }
