Commit 1aebdc73 authored by alexpott's avatar alexpott
Browse files

Issue #2048833 by larowlan, andypost: Fixed Prepare cache called on field...

Issue #2048833 by larowlan, andypost: Fixed Prepare cache called on field items without checking if PrepareCacheInterface is implemented.
parent 8043b9aa
......@@ -10,6 +10,7 @@
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
use Drupal\entity\Plugin\Core\Entity\EntityFormDisplay;
use Drupal\Core\Language\Language;
use Drupal\Core\Entity\Field\PrepareCacheInterface;
/**
* @defgroup field_storage Field Storage API
......@@ -678,7 +679,9 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
$definition = _field_generate_entity_field_definition($field, $options['instance']);
$items = \Drupal::typedData()->create($definition, $values, $field_name, $entity);
foreach ($items as $item) {
$item->prepareCache();
if ($item instanceof PrepareCacheInterface) {
$item->prepareCache();
}
}
$entity->{$field_name}[$langcode] = $items->getValue();
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\field\Plugin\field\field_type;
use Drupal\Core\Entity\Field\PrepareCacheInterface;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemBase;
use Drupal\field\Plugin\Core\Entity\Field;
......@@ -23,7 +24,7 @@
* @todo Remove once all core field types have been converted (see
* http://drupal.org/node/2014671).
*/
abstract class LegacyConfigFieldItem extends ConfigFieldItemBase {
abstract class LegacyConfigFieldItem extends ConfigFieldItemBase implements PrepareCacheInterface {
/**
* {@inheritdoc}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment