diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index e1f5fbc..320e7f5 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -1406,7 +1406,6 @@ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $st } $field_name = $storage_definition->getName(); - $field_description = $storage_definition->getDescription(); $base_table = $this->storage->getBaseTable(); // A shared table contains rows for entities where the field is empty @@ -1435,7 +1434,6 @@ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $st $column_schema = $field_schema['columns'][$field_column_name]; $schema['fields'][$schema_field_name] = $column_schema; - $schema['fields'][$schema_field_name]['description'] = $field_description; $schema['fields'][$schema_field_name]['not null'] = in_array($field_name, $not_null_keys); } diff --git a/core/modules/locale/src/Tests/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/src/Tests/LocaleTranslatedSchemaDefinitionTest.php new file mode 100644 index 0000000..da1bfe9 --- /dev/null +++ b/core/modules/locale/src/Tests/LocaleTranslatedSchemaDefinitionTest.php @@ -0,0 +1,59 @@ +save(); + $this->config('system.site')->set('langcode', 'fr')->save(); + drupal_flush_all_caches(); + } + + /** + * Tests translated and untranslated field labels and descriptions. + */ + function testTranslatedSchemaDefinition() { + $stringStorage = \Drupal::service('locale.storage'); + + $source = $stringStorage->createString(array( + 'source' => 'The node ID.', + ))->save(); + + $stringStorage->createTranslation(array( + 'lid' => $source->lid, + 'language' => 'fr', + 'translation' => 'Translated node ID', + ))->save(); + + // Ensure that the field is translated when access through the API. + $this->assertEqual('Translated node ID', \Drupal::entityManager()->getBaseFieldDefinitions('node')['nid']->getDescription()); + + // Assert there are no updates. + $this->assertFalse(\Drupal::service('entity.definition_update_manager')->needsUpdates()); + } +} diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php index 699bdba..fa50259 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php @@ -112,11 +112,9 @@ public function testGetSchemaBase() { 'columns' => array( 'value' => array( 'type' => 'text', - 'description' => 'The text value', ), 'format' => array( 'type' => 'varchar', - 'description' => 'The text description', ), ), )); @@ -248,95 +246,77 @@ public function testGetSchemaBase() { 'description' => 'The base table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'serial', 'not null' => TRUE, ), 'name' => array( - 'description' => 'The name field.', 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, ), 'description__value' => array( - 'description' => 'The description field.', 'type' => 'text', 'not null' => FALSE, ), 'description__format' => array( - 'description' => 'The description field.', 'type' => 'varchar', 'not null' => FALSE, ), 'uuid' => array( - 'description' => 'The uuid field.', 'type' => 'varchar', 'length' => 128, 'not null' => FALSE, ), 'hash' => array( - 'description' => 'The hash field.', 'type' => 'varchar', 'length' => 20, 'not null' => FALSE, ), 'email__username' => array( - 'description' => 'The email field.', 'type' => 'varchar', 'not null' => FALSE, ), 'email__hostname' => array( - 'description' => 'The email field.', 'type' => 'varchar', 'not null' => FALSE, ), 'email__domain' => array( - 'description' => 'The email field.', 'type' => 'varchar', 'not null' => FALSE, ), 'owner' => array( - 'description' => 'The owner field.', 'type' => 'int', 'not null' => FALSE, ), 'translator' => array( - 'description' => 'The translator field.', 'type' => 'int', 'not null' => FALSE, ), 'location__country' => array( - 'description' => 'The location field.', 'type' => 'varchar', 'not null' => FALSE, ), 'location__state' => array( - 'description' => 'The location field.', 'type' => 'varchar', 'not null' => FALSE, ), 'location__city' => array( - 'description' => 'The location field.', 'type' => 'varchar', 'not null' => FALSE, ), 'editor' => array( - 'description' => 'The editor field.', 'type' => 'int', 'not null' => FALSE, ), 'editor_revision__target_id' => array( - 'description' => 'The editor_revision field.', 'type' => 'int', 'not null' => FALSE, ), 'editor_revision__target_revision_id' => array( - 'description' => 'The editor_revision field.', 'type' => 'int', 'not null' => FALSE, ), 'long_index_name' => array( - 'description' => 'The long_index_name field.', 'type' => 'int', 'not null' => FALSE, ), @@ -439,12 +419,10 @@ public function testGetSchemaRevisionable() { 'description' => 'The base table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'serial', 'not null' => TRUE, ), 'revision_id' => array( - 'description' => 'The revision_id field.', 'type' => 'int', 'not null' => FALSE, ) @@ -465,12 +443,10 @@ public function testGetSchemaRevisionable() { 'description' => 'The revision table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'int', 'not null' => TRUE, ), 'revision_id' => array( - 'description' => 'The revision_id field.', 'type' => 'serial', 'not null' => TRUE, ), @@ -538,12 +514,10 @@ public function testGetSchemaTranslatable() { 'description' => 'The base table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'serial', 'not null' => TRUE, ), 'langcode' => array( - 'description' => 'The langcode field.', 'type' => 'varchar', 'not null' => TRUE, ) @@ -557,12 +531,10 @@ public function testGetSchemaTranslatable() { 'description' => 'The data table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'int', 'not null' => TRUE, ), 'langcode' => array( - 'description' => 'The langcode field.', 'type' => 'varchar', 'not null' => TRUE, ), @@ -645,17 +617,14 @@ public function testGetSchemaRevisionableTranslatable() { 'description' => 'The base table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'serial', 'not null' => TRUE, ), 'revision_id' => array( - 'description' => 'The revision_id field.', 'type' => 'int', 'not null' => FALSE, ), 'langcode' => array( - 'description' => 'The langcode field.', 'type' => 'varchar', 'not null' => TRUE, ) @@ -676,17 +645,14 @@ public function testGetSchemaRevisionableTranslatable() { 'description' => 'The revision table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'int', 'not null' => TRUE, ), 'revision_id' => array( - 'description' => 'The revision_id field.', 'type' => 'serial', 'not null' => TRUE, ), 'langcode' => array( - 'description' => 'The langcode field.', 'type' => 'varchar', 'not null' => TRUE, ), @@ -707,17 +673,14 @@ public function testGetSchemaRevisionableTranslatable() { 'description' => 'The data table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'int', 'not null' => TRUE, ), 'revision_id' => array( - 'description' => 'The revision_id field.', 'type' => 'int', 'not null' => TRUE, ), 'langcode' => array( - 'description' => 'The langcode field.', 'type' => 'varchar', 'not null' => TRUE, ), @@ -738,17 +701,14 @@ public function testGetSchemaRevisionableTranslatable() { 'description' => 'The revision data table for entity_test entities.', 'fields' => array( 'id' => array( - 'description' => 'The id field.', 'type' => 'int', 'not null' => TRUE, ), 'revision_id' => array( - 'description' => 'The revision_id field.', 'type' => 'int', 'not null' => TRUE, ), 'langcode' => array( - 'description' => 'The langcode field.', 'type' => 'varchar', 'not null' => TRUE, ), @@ -1242,10 +1202,6 @@ public function setUpStorageDefinition($field_name, array $schema) { $this->storageDefinitions[$field_name]->expects($this->any()) ->method('getName') ->will($this->returnValue($field_name)); - // getDescription() is called once for each table. - $this->storageDefinitions[$field_name]->expects($this->any()) - ->method('getDescription') - ->will($this->returnValue("The $field_name field.")); // getSchema() is called once for each table. $this->storageDefinitions[$field_name]->expects($this->any()) ->method('getSchema') diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index e90d145..ec24b1a 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -324,7 +324,6 @@ public function testOnEntityTypeCreate() { 'fields' => array( 'id' => array( 'type' => 'serial', - 'description' => NULL, 'not null' => TRUE, ), ),