diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index a1a1ebdb9e..28a1a21bb1 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -378,7 +378,6 @@ protected function defaultValueWidget(FormStateInterface $form_state) { * {@inheritdoc} */ public function equals(FieldItemListInterface $list_to_compare) { - $columns = $this->getFieldDefinition()->getFieldStorageDefinition()->getColumns(); $count1 = count($this); $count2 = count($list_to_compare); if ($count1 === 0 && $count2 === 0) { @@ -394,8 +393,15 @@ public function equals(FieldItemListInterface $list_to_compare) { if ($value1 === $value2) { return TRUE; } + // If the values are not equal ensure a consistent order of field item // properties and remove properties which will not be saved. + if ($this->getFieldDefinition()->isComputed()) { + $columns = $this->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinitions(); + } + else { + $columns = $this->getFieldDefinition()->getFieldStorageDefinition()->getColumns(); + } $callback = function (&$value) use ($columns) { if (is_array($value)) { $value = array_intersect_key($value, $columns);