diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php index 791f918..cf4e470 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/Field.php @@ -210,13 +210,6 @@ class Field extends ConfigEntityBase implements FieldInterface { protected $storageDetails; /** - * Flag indicating whether the field has data or not. - * - * @var bool - */ - protected $hasData; - - /** * Constructs a Field object. * * @param array $values @@ -645,34 +638,31 @@ public static function getReservedColumns() { * TRUE if the field has data for any entity; FALSE otherwise. */ public function hasData() { - if (!isset($this->hasData)) { - $storage_details = $this->getSchema(); - $columns = array_keys($storage_details['columns']); - $factory = \Drupal::service('entity.query'); - foreach ($this->getBundles() as $entity_type => $bundle) { - // Entity Query throws an exception if there is no base table. - $entity_info = \Drupal::entityManager()->getDefinition($entity_type); - if (!isset($entity_info['base_table'])) { - continue; - } - $query = $factory->get($entity_type); - $group = $query->orConditionGroup(); - foreach ($columns as $column) { - $group->exists($this->id() . '.' . $column); - } - $result = $query - ->condition($group) - ->count() - ->accessCheck(FALSE) - ->range(0, 1) - ->execute(); - if ($result) { - $this->hasData = TRUE; - } + $storage_details = $this->getSchema(); + $columns = array_keys($storage_details['columns']); + $factory = \Drupal::service('entity.query'); + foreach ($this->getBundles() as $entity_type => $bundle) { + // Entity Query throws an exception if there is no base table. + $entity_info = \Drupal::entityManager()->getDefinition($entity_type); + if (!isset($entity_info['base_table'])) { + continue; + } + $query = $factory->get($entity_type); + $group = $query->orConditionGroup(); + foreach ($columns as $column) { + $group->exists($this->id() . '.' . $column); + } + $result = $query + ->condition($group) + ->count() + ->accessCheck(FALSE) + ->range(0, 1) + ->execute(); + if ($result) { + return TRUE; } - $this->hasData = FALSE; } - return $this->hasData; + return FALSE; } }