diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/TaxonomyUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/TaxonomyUpgradePathTest.php new file mode 100644 index 0000000..3700212 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/TaxonomyUpgradePathTest.php @@ -0,0 +1,62 @@ + 'Taxonomy upgrade test', + 'description' => 'Taxonomy vocabulary and term upgrade tests.', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + $this->databaseDumpFiles = array( + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', + drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.taxonomy.database.php', + ); + parent::setUp(); + } + + /** + * Tests expected role ID conversions after a successful upgrade. + */ + public function testRoleUpgrade() { + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + + // Check the tags vocabulary. + $vocabulary = taxonomy_vocabulary_load('tags'); + $this->assertEqual($vocabulary->label(), 'Tags'); + $this->assertEqual($vocabulary->description, 'Use tags to group articles on similar topics into categories.'); + $this->assertTrue($vocabulary->uuid()); + + // Load the two prepared terms and assert them. + $term1 = taxonomy_term_load(5); + $this->assertEqual($term1->label(), 'A tag'); + $this->assertEqual($term1->vid->value, 'tags'); + $this->assertEqual($term1->bundle(), 'tags'); + $this->assertEqual($term1->taxonomy_term_description->value, 'Description of a tag'); + $this->assertEqual($term1->taxonomy_term_description->format, 'plain_text'); + + $term2 = taxonomy_term_load(6); + $this->assertEqual($term2->label(), 'Another tag'); + $this->assertEqual($term2->vid->value, 'tags'); + $this->assertEqual($term2->bundle(), 'tags'); + $this->assertEqual($term2->taxonomy_term_description->value, 'HTML Description'); + $this->assertEqual($term2->taxonomy_term_description->format, 'filtered_html'); + } + +} diff --git a/core/modules/system/tests/upgrade/drupal-7.taxonomy.database.php b/core/modules/system/tests/upgrade/drupal-7.taxonomy.database.php new file mode 100644 index 0000000..d3dcb3f --- /dev/null +++ b/core/modules/system/tests/upgrade/drupal-7.taxonomy.database.php @@ -0,0 +1,31 @@ +fields(array('tid', 'vid', 'name', 'description', 'format', 'weight')) + ->values(array( + 'tid' => 5, + 'vid' => 1, + 'name' => 'A tag', + 'description' => 'Description of a tag', + 'format' => 'plain_text', + 'weight' => 10, + )) + ->values(array( + 'tid' => 6, + 'vid' => 1, + 'name' => 'Another tag', + 'description' => 'HTML Description', + 'format' => 'filtered_html', + 'weight' => 20, + )) + ->execute(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php index bea7976..847a68b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php @@ -143,17 +143,6 @@ public function baseFieldDefinitions() { 'description' => t('The term name.'), 'type' => 'string_field', ); - $properties['description'] = array( - 'label' => t('Description'), - 'description' => t('A description of the term'), - 'type' => 'string_field', - ); - // @todo Combine with description. - $properties['format'] = array( - 'label' => t('Description format'), - 'description' => t('The filter format ID of the description.'), - 'type' => 'string_field', - ); $properties['weight'] = array( 'label' => t('Weight'), 'description' => t('The weight of this term in relation to other terms.'), diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index a18b46c..f798b93 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -385,25 +385,40 @@ function taxonomy_update_8008(&$sandbox) { $sandbox['max'] = db_query('SELECT COUNT(DISTINCT tid) FROM {taxonomy_term_data} WHERE vid > 0')->fetchField(); } - $terms = db_query_range('SELECT t.tid, t.description, t.format, v.machine_name FROM {taxonomy_term_data} t INNER JOIN {taxonomy_vocabulary} v ON t.vid = v.vid WHERE tid > :tid ORDER BY tid ASC', 0, 100, array(':tid' => $sandbox['current_tid'])); + $terms = db_query_range('SELECT t.tid, t.description, t.format, t.vid FROM {taxonomy_term_data} t WHERE tid > :tid ORDER BY tid ASC', 0, 100, array(':tid' => $sandbox['current_tid'])); + $data = db_insert('field_data_taxonomy_term_description') + ->fields(array('entity_type', 'bundle', 'entity_id', 'revision_id', 'langcode', 'delta', 'taxonomy_term_description_value', 'taxonomy_term_description_format')); + $revision = db_insert('field_revision_taxonomy_term_description') + ->fields(array('entity_type', 'bundle', 'entity_id', 'revision_id', 'langcode', 'delta', 'taxonomy_term_description_value', 'taxonomy_term_description_format')); foreach ($terms as $term) { - db_insert('field_data_taxonomy_term_description') - ->fields(array( + $data->values(array( 'entity_type' => 'taxonomy_term', - 'bundle' => $term->machine_name, + 'bundle' => $term->vid, 'entity_id' => $term->tid, 'revision_id' => $term->tid, 'langcode' => LANGUAGE_NOT_SPECIFIED, 'delta' => 0, 'taxonomy_term_description_value' => $term->description, 'taxonomy_term_description_format' => $term->format, - )) - ->execute(); + )); + $revision->fields(array( + 'entity_type' => 'taxonomy_term', + 'bundle' => $term->vid, + 'entity_id' => $term->tid, + 'revision_id' => $term->tid, + 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'delta' => 0, + 'taxonomy_term_description_value' => $term->description, + 'taxonomy_term_description_format' => $term->format, + )); $sandbox['progress']++; $sandbox['current_tid'] = $term->tid; } + $data->execute(); + $revision->execute(); + $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']); }