diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 8e4deba..7cf2524 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -1418,7 +1418,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 @@ -1447,7 +1446,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..4f933ce --- /dev/null +++ b/core/modules/locale/src/Tests/LocaleTranslatedSchemaDefinitionTest.php @@ -0,0 +1,93 @@ +save(); + $this->config('system.site')->set('langcode', 'fr')->save(); + // Clear all caches so that the base field definition, its cache in + // the entity manager, the t() cache, etc. are all cleared. + drupal_flush_all_caches(); + } + + /** + * Tests that translated field descriptions do not affect the update system. + */ + function testTranslatedSchemaDefinition() { + /** @var \Drupal\locale\StringDatabaseStorage $stringStorage */ + $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()); + } + + /** + * Tests that translations do not affect the update system. + */ + function testTranslatedUpdate() { + // Visit the update page to collect any strings that may be translatable. + $user = $this->drupalCreateUser(array('administer software updates')); + $this->drupalLogin($user); + $update_url = $GLOBALS['base_url'] . '/update.php'; + $this->drupalGet($update_url, array('external' => TRUE)); + + /** @var \Drupal\locale\StringDatabaseStorage $stringStorage */ + $stringStorage = \Drupal::service('locale.storage'); + $sources = $stringStorage->getStrings(); + + // Translate all source strings found. + foreach ($sources as $source) { + $stringStorage->createTranslation(array( + 'lid' => $source->lid, + 'language' => 'fr', + 'translation' => $this->randomMachineName(100), + ))->save(); + } + + // Ensure that there are no updates just due to translations. Check for + // markup and a link instead of specific text because text may be + // translated. + $this->drupalGet($update_url . '/selection', array('external' => TRUE)); + $this->assertRaw('messages--status', 'No pending updates.'); + $this->assertNoLinkByHref('fr/update.php/run', 'No link to run updates.'); + } +} 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, ), ),