diff --git a/core/lib/Drupal/Core/TypedData/Validation/PropertyContainerMetadata.php b/core/lib/Drupal/Core/TypedData/Validation/PropertyContainerMetadata.php index 0b16ae8..f5850eb 100644 --- a/core/lib/Drupal/Core/TypedData/Validation/PropertyContainerMetadata.php +++ b/core/lib/Drupal/Core/TypedData/Validation/PropertyContainerMetadata.php @@ -28,7 +28,7 @@ public function accept(ValidationVisitorInterface $visitor, $typed_data, $group, $typed_data = NULL; } $visitor->visit($this, $typed_data, $group, $propertyPath); - $pathPrefix = empty($propertyPath) ? '' : $propertyPath . '.'; + $pathPrefix = isset($propertyPath) && $propertyPath !== '' ? $propertyPath . '.' : ''; if ($typed_data) { foreach ($typed_data as $name => $data) { diff --git a/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php index 3ee8722..83f5f4e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\TypedData; +use Drupal\Component\Utility\String; use Drupal\simpletest\DrupalUnitTestBase; use Drupal\Core\Datetime\DrupalDateTime; use DateInterval; @@ -548,5 +549,19 @@ public function testTypedDataValidation() { $this->assertEqual($violations->count(), 1); $violations = $this->typedData->create($definition, 0)->validate(); $this->assertEqual($violations->count(), 0); + + // Test validating a list of a values and make sure property paths starting + // with "0" are created. + $definition = array( + 'type' => 'integer_field', + 'list' => TRUE, + ); + $violations = $this->typedData->create($definition, array(array('value' => 10)))->validate(); + $this->assertEqual($violations->count(), 0); + $violations = $this->typedData->create($definition, array(array('value' => 'string')))->validate(); + $this->assertEqual($violations->count(), 1); + + $this->assertEqual($violations[0]->getInvalidValue(), 'string'); + $this->assertIdentical($violations[0]->getPropertyPath(), '0.value'); } }