diff --git a/core/modules/path/src/PathAliasComputed.php b/core/modules/path/src/PathAliasComputed.php index 25e1869b23..29e2d8ed47 100644 --- a/core/modules/path/src/PathAliasComputed.php +++ b/core/modules/path/src/PathAliasComputed.php @@ -29,13 +29,15 @@ public function getValue($langcode = NULL) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ if (($field_item = $this->getParent()) && ($entity = $field_item->getEntity()) && $entity->id()) { + // We use an array as https://www.drupal.org/node/2511968 will introduce + // fallback options. $possible_langcodes = []; - $possible_langcodes[] = $langcode; if ($field_item->getLangcode() !== LanguageInterface::LANGCODE_NOT_SPECIFIED) { $possible_langcodes[] = $field_item->getLangcode(); } - $possible_langcodes[] = $entity->getLangcode(); - $possible_langcodes[] = LanguageInterface::LANGCODE_NOT_SPECIFIED; + else { + $possible_langcodes[] = NULL; + } $alias = NULL; foreach ($possible_langcodes as $possible_langcode) { @@ -45,7 +47,6 @@ public function getValue($langcode = NULL) { } } - // Mimic the field structure that would be returned if this field // contained any items. $this->alias = $alias; diff --git a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php index c3001c1fb9..2b2e862f87 100644 --- a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php +++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php @@ -5,7 +5,6 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Language\LanguageInterface; use Symfony\Component\Validator\ConstraintViolationInterface; /**