core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php | 3 +++ core/modules/path/src/Plugin/Field/FieldType/PathItem.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php b/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php index 1a5fbe0..ad1d762 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathFieldItemList.php @@ -39,6 +39,9 @@ protected function computeValue() { } $this->list[0] = $this->createItem(0, $value); + // If no alias actually exists remove the empty item. This ensures that + // count() will not return 1 for an empty list. + $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 65cb14b..1f4246b 100644 --- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php @@ -47,7 +47,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) * {@inheritdoc} */ public function isEmpty() { - return ($this->alias === NULL || $this->alias === '') && ($this->pid === NULL || $this->pid === '') && ($this->langcode === NULL || $this->langcode === ''); + return ($this->alias === NULL || $this->alias === '') && ($this->pid === NULL || $this->pid === ''); } /**