Issue #2048833 by larowlan, andypost: Fixed Prepare cache called on field items without checking if PrepareCacheInterface is implemented.

8.0.x
Alex Pott 2013-07-26 17:58:50 +02:00
parent 8043b9aa34
commit 1aebdc7390
2 changed files with 6 additions and 2 deletions

View File

@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityNG;
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();
}

View File

@ -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 @@ use Drupal\field\Plugin\Core\Entity\Field;
* @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}