diff -u b/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php --- b/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -266,7 +266,7 @@ $parents[0] = NULL; continue; } - $ids[] = $item->target_id; + $ids[] = $item->target_id; } // @todo Better way to do this? AND handle the NULL/0 parent? diff -u b/core/modules/taxonomy/src/TermViewsData.php b/core/modules/taxonomy/src/TermViewsData.php --- b/core/modules/taxonomy/src/TermViewsData.php +++ b/core/modules/taxonomy/src/TermViewsData.php @@ -229,8 +229,13 @@ 'field' => 'parent_target_id', ]; - $data['taxonomy_term__parent']['parent_target_id']['help'] = $this->t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'); - $data['taxonomy_term__parent']['parent_target_id']['argument']['id'] = 'taxonomy'; + $data['taxonomy_term__parent']['parent']['help'] = $this->t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'); + $data['taxonomy_term__parent']['parent']['argument']['id'] = 'taxonomy'; + $data['taxonomy_term__parent']['parent']['argument']['field'] = 'parent_target_id'; + $data['taxonomy_term__parent']['parent']['relationship']['field'] = 'parent_target_id'; + $data['taxonomy_term__parent']['parent']['relationship']['label'] = $this->t('Parent'); + $data['taxonomy_term__parent']['parent']['filter']['field'] = 'parent_target_id'; + $data['taxonomy_term__parent']['parent']['sort']['field'] = 'parent_target_id'; return $data; } diff -u b/core/modules/taxonomy/src/VocabularyStorageInterface.php b/core/modules/taxonomy/src/VocabularyStorageInterface.php --- b/core/modules/taxonomy/src/VocabularyStorageInterface.php +++ b/core/modules/taxonomy/src/VocabularyStorageInterface.php @@ -18,7 +18,7 @@ * @return array * Array of top-level term IDs. * - * @deprecated in Drupal 8.2.x, will be removed in Drupal 9.0.x Use + * @deprecated in Drupal 8.3.x, will be removed in Drupal 9.0.x Use * \Drupal\taxonomy\Entity\Vocabulary::getTopLevelTids($vids) instead. */ public function getToplevelTids($vids); diff -u b/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install --- b/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -6,14 +6,14 @@ */ /** - * @addtogroup updates-8.2.x + * @addtogroup updates-8.3.x * @{ */ /** * Convert the custom taxonomy term hierarchy storage to a default storage. */ -function taxonomy_update_8201() { +function taxonomy_update_8301() { $manager = \Drupal::entityDefinitionUpdateManager(); /** @var \Drupal\Core\Field\BaseFieldDefinition $definition */ $definition = $manager->getFieldStorageDefinition('parent', 'taxonomy_term'); @@ -26,7 +26,7 @@ /** * Copy hierarchy from {taxonomy_term_hierarchy} to {taxonomy_term__parent}. */ -function taxonomy_update_8202(&$sandbox) { +function taxonomy_update_8302(&$sandbox) { $database = \Drupal::database(); if (!isset($sandbox['current'])) { @@ -73,16 +73,15 @@ $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['current'] / $sandbox['max']); if ($sandbox['#finished'] >= 1) { - // Drop the legacy table. - $database->schema()->dropTable('taxonomy_term_hierarchy'); return t('Taxonomy term hierarchy converted.'); } + return t('Taxonomy term hierarchy NOT FULLY converted.'); } /** * Update views to use {taxonomy_term__parent} in relationships. */ -function taxonomy_update_8203() { +function taxonomy_update_8303() { $config_factory = \Drupal::configFactory(); foreach ($config_factory->listAll('views.view.') as $id) { $view = $config_factory->getEditable($id); @@ -92,8 +91,15 @@ if (!empty($table = $view->get($path)) && $table == 'taxonomy_term_hierarchy') { $view->set($path, 'taxonomy_term__parent'); - $path = "display.$display_id.display_options.relationships.parent.field"; - $view->set($path, 'parent_target_id'); + $path = "display.{$display_id}.display_options.filters.parent.table"; + if (!empty($table = $view->get($path)) && $table == 'taxonomy_term_hierarchy') { + $view->set($path, 'taxonomy_term__parent'); + } + + $path = "display.{$display_id}.display_options.arguments.parent.table"; + if (!empty($table = $view->get($path)) && $table == 'taxonomy_term_hierarchy') { + $view->set($path, 'taxonomy_term__parent'); + } $changed = TRUE; } @@ -106,4 +112,16 @@ + + +/** + * Drop the legacy table {taxonomy_term_hierarchy}. + */ +function taxonomy_update_8304(&$sandbox) { + $database = \Drupal::database(); + // Drop the legacy table. + $database->schema()->dropTable('taxonomy_term_hierarchy'); + return t('Taxonomy term legacy tables dropped.'); +} + /** - * @} End of "addtogroup updates-8.2.x". + * @} End of "addtogroup updates-8.3.x". */ only in patch2: unchanged: --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -433,7 +433,7 @@ public function createForum($type, $parent = 0) { // Verify forum hierarchy. $tid = $term['tid']; - $parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", [':tid' => $tid])->fetchField(); + $parent_tid = db_query("SELECT t.parent_target_id FROM {taxonomy_term__parent} t WHERE t.entity_id = :tid", [':tid' => $tid])->fetchField(); $this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container'); $forum = $this->container->get('entity.manager')->getStorage('taxonomy_term')->load($tid);