diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index c1e3f97..d80966a 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -35,7 +35,7 @@ class CommentStorageController extends DatabaseStorageController { /** * Overrides Drupal\entity\DatabaseStorageController::attachLoad(). */ - protected function attachLoad(&$comments, $revision_id = FALSE) { + protected function attachLoad(&$comments, $load_revision = FALSE) { // Set up standard comment properties. foreach ($comments as $key => $comment) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; @@ -43,7 +43,7 @@ class CommentStorageController extends DatabaseStorageController { $comment->node_type = 'comment_node_' . $comment->node_type; $comments[$key] = $comment; } - parent::attachLoad($comments, $revision_id); + parent::attachLoad($comments, $load_revision); } /** diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index 483028f..f96c6a2 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -136,7 +136,7 @@ function entity_info_cache_clear() { * @param bool $reset * Whether to reset the internal cache for the requested entity type. * - * @return object + * @return Drupal\entity\EntityInterface * The entity object, or FALSE if there is no entity with the given id. * * @see hook_entity_info() @@ -158,7 +158,7 @@ function entity_load($entity_type, $id, $reset = FALSE) { * @param int $revision_id * The id of the entity to load. * - * @return object + * @return Drupal\entity\EntityInterface * The entity object, or FALSE if there is no entity with the given revision * id. * @@ -189,9 +189,6 @@ function entity_revision_load($entity_type, $revision_id) { * Thrown in case the requested entity type does not support UUIDs. * * @see hook_entity_info() - * - * @todo D8: Make it easier to query entities by property; e.g., enhance - * EntityStorageControllerInterface with a ::loadByProperty() method. */ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) { $entity_info = entity_get_info($entity_type); @@ -253,9 +250,8 @@ function entity_load_multiple($entity_type, $ids = FALSE, $reset = FALSE) { * @param string $entity_type * The entity type to load, e.g. node or user. * @param array $values - * An associative array of properties of the entity, where - * the keys are the property names and the values are the values those - * properties must have. + * An associative array of properties of the entity, where the keys are the + * property names and the values are the values those properties must have. * * @return array * An array of entity objects indexed by their ids. diff --git a/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php b/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php index 10f198c..e064e28 100644 --- a/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php +++ b/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php @@ -227,7 +227,7 @@ class DatabaseStorageController implements EntityStorageControllerInterface { // which attaches fields (if supported by the entity type) and calls the // entity type specific load callback, for example hook_node_load(). if (!empty($queried_entities)) { - $this->attachLoad($queried_entities, $revision_id); + $this->attachLoad($queried_entities, TRUE); } return reset($queried_entities); } @@ -255,9 +255,8 @@ class DatabaseStorageController implements EntityStorageControllerInterface { * @param Drupal\entity\EntityFieldQuery $entity_query * EntityFieldQuery instance. * @param array $values - * An associative array of properties of the entity, where - * the keys are the property names and the values are the values those - * properties must have. + * An associative array of properties of the entity, where the keys are the + * property names and the values are the values those properties must have. */ protected function buildPropertyQuery(EntityFieldQuery $entity_query, array $values) { foreach ($values as $name => $value) { @@ -343,14 +342,13 @@ class DatabaseStorageController implements EntityStorageControllerInterface { * * @param $queried_entities * Associative array of query results, keyed on the entity ID. - * @param $revision_id - * ID of the revision that was loaded, or FALSE if the most current revision - * was loaded. + * @param $load_revision + * (optional) TRUE if the revision should be loaded, defaults to FALSE. */ - protected function attachLoad(&$queried_entities, $revision_id = FALSE) { + protected function attachLoad(&$queried_entities, $load_revision = FALSE) { // Attach fields. if ($this->entityInfo['fieldable']) { - if ($revision_id) { + if ($load_revision) { field_attach_load_revision($this->entityType, $queried_entities); } else { diff --git a/core/modules/entity/lib/Drupal/entity/EntityStorageControllerInterface.php b/core/modules/entity/lib/Drupal/entity/EntityStorageControllerInterface.php index abd4999..f11d812 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityStorageControllerInterface.php +++ b/core/modules/entity/lib/Drupal/entity/EntityStorageControllerInterface.php @@ -63,9 +63,8 @@ interface EntityStorageControllerInterface { * Load entities by their properties. * * @param array $values - * An associative array of properties of the entity, where - * the keys are the property names and the values are the values those - * properties must have. + * An associative array of properties of the entity, where the keys are the + * property names and the values are the values those properties must have. * * @return array * An array of entity objects indexed by their ids. diff --git a/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php b/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php index ad53689..b31e5ce 100644 --- a/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php +++ b/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php @@ -60,7 +60,7 @@ class EntityTestStorageController extends DatabaseStorageController { /** * Overrides Drupal\entity\DatabaseStorageController::attachLoad(). */ - protected function attachLoad(&$queried_entities, $revision_id = FALSE) { + protected function attachLoad(&$queried_entities, $load_revision = FALSE) { $data = db_select('entity_test_property_data', 'data', array('fetch' => PDO::FETCH_ASSOC)) ->fields('data') ->condition('id', array_keys($queried_entities)) @@ -78,7 +78,7 @@ class EntityTestStorageController extends DatabaseStorageController { $entity->setProperties($values, $langcode); } - parent::attachLoad($queried_entities, $revision_id); + parent::attachLoad($queried_entities, $load_revision); } /** diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php index 7df6bc9..d4968a6 100644 --- a/core/modules/node/lib/Drupal/node/NodeStorageController.php +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php @@ -157,7 +157,7 @@ class NodeStorageController extends DatabaseStorageController { /** * Overrides Drupal\entity\DatabaseStorageController::attachLoad(). */ - protected function attachLoad(&$nodes, $revision_id = FALSE) { + protected function attachLoad(&$nodes, $load_revision = FALSE) { // Create an array of nodes for each content type and pass this to the // object type specific callback. $typed_nodes = array(); @@ -176,7 +176,7 @@ class NodeStorageController extends DatabaseStorageController { // hook_node_load(), containing a list of node types that were loaded. $argument = array_keys($typed_nodes); $this->hookLoadArguments = array($argument); - parent::attachLoad($nodes, $revision_id); + parent::attachLoad($nodes, $load_revision); } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 5598863..58afe14 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -157,13 +157,15 @@ abstract class WebTestBase extends TestBase { * @param $title * A node title, usually generated by $this->randomName(). * @param $reset - * (optional) Whether to reset the internal node_load() cache. + * (optional) Whether to reset the entity cache. * * @return * A node entity matching $title. */ function drupalGetNodeByTitle($title, $reset = FALSE) { - entity_get_controller('node')->resetCache(); + if ($reset) { + entity_get_controller('node')->resetCache(); + } $nodes = entity_load_by_properties('node', array('title' => $title)); // Load the first node returned from the database. $returned_node = reset($nodes); diff --git a/core/modules/user/lib/Drupal/user/UserStorageController.php b/core/modules/user/lib/Drupal/user/UserStorageController.php index bde430c..3e2ac68 100644 --- a/core/modules/user/lib/Drupal/user/UserStorageController.php +++ b/core/modules/user/lib/Drupal/user/UserStorageController.php @@ -22,7 +22,7 @@ class UserStorageController extends DatabaseStorageController { /** * Overrides Drupal\entity\DatabaseStorageController::attachLoad(). */ - function attachLoad(&$queried_users, $revision_id = FALSE) { + function attachLoad(&$queried_users, $load_revision = FALSE) { // Build an array of user picture IDs so that these can be fetched later. $picture_fids = array(); foreach ($queried_users as $key => $record) { @@ -56,7 +56,7 @@ class UserStorageController extends DatabaseStorageController { } // Call the default attachLoad() method. This will add fields and call // hook_user_load(). - parent::attachLoad($queried_users, $revision_id); + parent::attachLoad($queried_users, $load_revision); } /**