diff --git a/core/lib/Drupal/Core/Entity/Field/PrepareCacheInterface.php b/core/lib/Drupal/Core/Entity/Field/PrepareCacheInterface.php index 6cdf575..7f57c53 100644 --- a/core/lib/Drupal/Core/Entity/Field/PrepareCacheInterface.php +++ b/core/lib/Drupal/Core/Entity/Field/PrepareCacheInterface.php @@ -10,26 +10,25 @@ /** * Interface for preparing field values before they enter cache. * - * If a field type implements this interface, the getCacheValue() method will be - * invoked instead of getValue(). - * + * If a field type implements this interface, this method will be used instead + * of the regular getValue() to collect the data to include in the cache of + * field values. */ interface PrepareCacheInterface { /** - * Massages loaded field values before they enter the field cache. + * Returns the data to store in the field cache. * - * You should never load fieldable entities within this method, since this is - * likely to cause infinite recursions. Use the prepareView() method instead. + * This method is called if the entity type has field caching enabled, when an + * entity is loaded and no existing cache entry was found in the field cache. * - * 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 those elements in - * case they are not present. + * This method should never trigger the loading of fieldable entities, since + * this is likely to cause infinite recursions. A common workaround is to + * provide a base formatter class implementing the prepareView() method + * instead. * - * The method is also only called if the entity has field caching enabled. The - * recommended way to implement it is by providing a computed field item - * property that an also hold a value set with setValue(). See + * The recommended way to implement it is to provide a computed field item + * property that can accepts setting a value through setValue(). See * \Drupal\text\Plugin\field\field_type\TextItemBase and the corresponding * computed property Drupal\text\TextProcessed for an example. */ diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php index d7e6272..c5df7ea 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/field/field_type/DateTimeItem.php @@ -148,10 +148,7 @@ public function isEmpty() { * {@inheritdoc} */ public function onChange($property_name) { - // Notify the parent of changes. - if (isset($this->parent)) { - $this->parent->onChange($this->name); - } + parent::onChange($property_name); // Enforce that the computed date is recalculated. if ($property_name == 'value') { diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php index 9ac29f3..fc6be34 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php @@ -344,11 +344,4 @@ public function getUploadValidators() { return $validators; } - /** - * {@inheritdoc} - */ - public function prepareCache() { - return $this->getValue(); - } - }