diff -u b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php --- b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -165,13 +165,15 @@ $meta = config_typed()->get('system.site'); $property = $meta->get('name'); $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the site name property.'); - $this->assertEqual($property->getPluginId(), 'label', 'Got the right string type for site name data.'); $this->assertEqual($property->getValue(), 'Drupal', 'Got the right string value for site name data.'); + $definition = $property->getDefinition(); + $this->assertTrue($definition['translatable'], 'Got the right translatability setting for site name data.'); $property = $meta->get('page')->get('front'); $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the page.front property.'); - $this->assertEqual($property->getPluginId(), 'path', 'Got the right type for page.front data (undefined).'); $this->assertEqual($property->getValue(), 'user', 'Got the right value for page.front data.'); + $definition = $property->getDefinition(); + $this->assertTrue(empty($definition['translatable']), 'Got the right translatability setting for page.front data.'); // Check nested array of properties. $list = $meta->get('page'); diff -u b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php --- b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/TypedData/TypedDataTest.php @@ -47,17 +47,13 @@ } /** - * Creates a typed data object and executes some basic assertions. + * Creates a typed data object and ensures it implements TypedDataInterface. * * @see Drupal\Core\TypedData\TypedDataManager::create(). */ protected function createTypedData($definition, $value = NULL, $name = NULL) { - // Construct the object. $data = $this->typedData->create($definition, $value, $name); - // Assert the definition of the wrapper. $this->assertTrue($data instanceof \Drupal\Core\TypedData\TypedDataInterface, 'Typed data object is an instance of the typed data interface.'); - $definition = $data->getDefinition(); - $this->assertTrue(!empty($definition['type']), format_string('!type data definition was returned.', array('!type' => $definition['type']))); return $data; } @@ -67,6 +63,7 @@ public function testGetAndSet() { // Boolean type. $typed_data = $this->createTypedData(array('type' => 'boolean'), TRUE); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\BooleanInterface, 'Typed data object is an instance of BooleanInterface.'); $this->assertTrue($typed_data->getValue() === TRUE, 'Boolean value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue(FALSE); @@ -82,6 +79,7 @@ // String type. $value = $this->randomString(); $typed_data = $this->createTypedData(array('type' => 'string'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\StringInterface, 'Typed data object is an instance of StringInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'String value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = $this->randomString(); @@ -99,6 +97,7 @@ // Integer type. $value = rand(); $typed_data = $this->createTypedData(array('type' => 'integer'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\IntegerInterface, 'Typed data object is an instance of IntegerInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'Integer value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = rand(); @@ -115,6 +114,7 @@ // Float type. $value = 123.45; $typed_data = $this->createTypedData(array('type' => 'float'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\FloatInterface, 'Typed data object is an instance of FloatInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'Float value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = 678.90; @@ -131,6 +131,7 @@ // Date Time type. $value = '2014-01-01T20:00:00+00:00'; $typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); $this->assertTrue($typed_data->getValue() == $value, 'Date value was fetched.'); $this->assertEqual($typed_data->getValue(), $typed_data->getDateTime()->format('c'), 'Value representation of a date is ISO 8601'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -156,6 +157,7 @@ // Timestamp type. $value = REQUEST_TIME; $typed_data = $this->createTypedData(array('type' => 'timestamp'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); $this->assertTrue($typed_data->getValue() == $value, 'Timestamp value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $new_value = REQUEST_TIME + 1; @@ -178,6 +180,7 @@ // DurationIso8601 type. $value = 'PT20S'; $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DurationInterface, 'Typed data object is an instance of DurationInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'DurationIso8601 value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue('P40D'); @@ -201,6 +204,7 @@ // Time span type. $value = 20; $typed_data = $this->createTypedData(array('type' => 'timespan'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DurationInterface, 'Typed data object is an instance of DurationInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'Time span value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue(60 * 60 * 4); @@ -223,6 +227,7 @@ // URI type. $uri = 'http://example.com/foo/'; $typed_data = $this->createTypedData(array('type' => 'uri'), $uri); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\UriInterface, 'Typed data object is an instance of UriInterface.'); $this->assertTrue($typed_data->getValue() === $uri, 'URI value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); $typed_data->setValue($uri . 'bar.txt'); @@ -249,6 +254,7 @@ // Email type. $value = $this->randomString(); $typed_data = $this->createTypedData(array('type' => 'email'), $value); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\StringInterface, 'Typed data object is an instance of StringInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'E-mail value was fetched.'); $new_value = 'test@example.com'; $typed_data->setValue($new_value); @@ -263,6 +269,7 @@ // Binary type. $typed_data = $this->createTypedData(array('type' => 'binary'), $files[0]->getFileUri()); + $this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\BinaryInterface, 'Typed data object is an instance of BinaryInterface.'); $this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); // Try setting by URI. diff -u b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php --- b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php +++ b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextItemBase.php @@ -70,7 +70,7 @@ /** * {@inheritdoc} */ - public function prepareCache() { + public function prepareCache($properties = array('value')) { // Where possible, generate the sanitized version of each field early so // that it is cached in the field cache. This avoids the need to look up the // field in the filter cache separately. @@ -78,9 +78,8 @@ if (!$text_processing || filter_format_allowcache($this->get('format')->getValue())) { $itemBC = $this->getValue(); $langcode = $this->getParent()->getParent()->language()->id; - $this->set('safe_value', text_sanitize($text_processing, $langcode, $itemBC, 'value')); - if ($this->getPluginId() == 'field_item:text_with_summary') { - $this->set('safe_summary', text_sanitize($text_processing, $langcode, $itemBC, 'summary')); + foreach ($properties as $name) { + $this->set("safe_$name", text_sanitize($text_processing, $langcode, $itemBC, $name)); } } } only in patch2: unchanged: --- a/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextWithSummaryItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/field/field_type/TextWithSummaryItem.php @@ -128,4 +128,11 @@ public function instanceSettingsForm(array $form, array &$form_state) { return $element; } + /** + * {@inheritdoc} + */ + public function prepareCache($properties = array('value', 'summary')) { + parent::prepareCache($properties); + } + }