diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php b/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php index 07649aeba7..2b8a3c3bcc 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php @@ -81,9 +81,7 @@ protected function ensureLoaded() { $this->list[0] = $this->createItem(0); // If no alias actually exists remove the empty item. This ensures that // count() will not return 1 for an empty list. - if ($this->list[0]->isEmpty()) { - unset($this->list[0]); - } + $this->filterEmptyItems(); } } diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php index bf43f154e0..7115728348 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php @@ -179,7 +179,7 @@ protected function ensureLoaded() { // language. // @todo Set the langcode to not specified for untranslatable fields // in https://www.drupal.org/node/2689459. - $this->langcode = $this->getLangcode(); + $this->langcode = $this->getLangcode(); } } $this->isLoaded = TRUE; diff --git a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php index 13ab1f1076..a6f8809c68 100644 --- a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php +++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php @@ -47,7 +47,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen ]; $element['langcode'] = [ '#type' => 'value', - '#value' => $items[$delta]->langcode, + '#value' => $items[$delta]->langcode?: $entity->language()->getId(), ]; return $element; }