diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php index 913ab07..8fd79e4 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -653,6 +653,8 @@ public function invokeFieldMethod($method, EntityInterface $entity) { * The entity object. */ public function invokeFieldItemPrepareCache(EntityInterface $entity) { + // @todo getTranslationLanguages() relies on $entity->getProperties() which + // initializes all field objects, annihilating the optimisation. foreach (array_keys($entity->getTranslationLanguages()) as $langcode) { // @todo getTranslation() only works on NG entities. Remove the condition // and the second code branch when all core entity types are converted. diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/PrepareCacheInterface.php b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/PrepareCacheInterface.php index ffed419..4440b01 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/PrepareCacheInterface.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/FieldType/PrepareCacheInterface.php @@ -19,6 +19,11 @@ * * You should never load fieldable entities within this method, since this is * likely to cause infinite recursions. Use the prepareView() method instead. + * + * Also note that the method is not called on field values displayed during + * entity preview. If the method adds elements that might be needed during + * display, you might want to also use prepareView() to add it in case it is + * not present. */ public function prepareCache(); diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 37ad20c..673e63d 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -110,12 +110,6 @@ function node_add($node_type) { */ function node_preview(EntityInterface $node) { if (node_access('create', $node) || node_access('update', $node)) { - // Invoke the prepareCache() method on field items, as if they were loaded - // from storage. - Drupal::entityManager() - ->getStorageController('node') - ->invokeFieldItemPrepareCache($node); - // Load the user's name when needed. if (isset($node->name)) { // The use of isset() is mandatory in the context of user IDs, because