diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 7cc950f..d549abc 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -300,11 +300,11 @@ function forum_node_validate(EntityInterface $node, $form) { foreach ($node->taxonomy_forums[$langcode] as $delta => $item) { // If no term was selected (e.g. when no terms exist yet), remove the // item. - if (empty($item['tid'])) { + if (empty($item['target_id'])) { unset($node->taxonomy_forums[$langcode][$delta]); continue; } - $term = taxonomy_term_load($item['tid']); + $term = taxonomy_term_load($item['target_id']); if (!$term) { form_set_error('taxonomy_forums', t('Select a forum.')); continue; @@ -333,13 +333,13 @@ function forum_node_presave(EntityInterface $node) { reset($node->taxonomy_forums); $langcode = key($node->taxonomy_forums); if (!empty($node->taxonomy_forums[$langcode])) { - $node->forum_tid = $node->taxonomy_forums[$langcode][0]['tid']; + $node->forum_tid = $node->taxonomy_forums[$langcode][0]['target_id']; // Only do a shadow copy check if this is not a new node. if (!$node->isNew()) { $old_tid = db_query_range("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, array(':nid' => $node->nid))->fetchField(); if ($old_tid && isset($node->forum_tid) && ($node->forum_tid != $old_tid) && !empty($node->shadow)) { // A shadow copy needs to be created. Retain new term and add old term. - $node->taxonomy_forums[$langcode][] = array('tid' => $old_tid); + $node->taxonomy_forums[$langcode][] = array('target_id' => $old_tid); } } } @@ -538,7 +538,7 @@ function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) $query->values(array( 'nid' => $entity->id(), 'title' => $translation->title->value, - 'tid' => $translation->taxonomy_forums->tid, + 'tid' => $translation->taxonomy_forums->target_id, 'sticky' => $entity->sticky, 'created' => $entity->created, 'comment_count' => 0, @@ -573,7 +573,7 @@ function forum_field_storage_pre_update(EntityInterface $entity, &$skip_fields) $query->values(array( 'nid' => $entity->nid, 'title' => $entity->title, - 'tid' => $item['tid'], + 'tid' => $item['target_id'], 'sticky' => $entity->sticky, 'created' => $entity->created, 'comment_count' => 0, diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index f8c0479..c28b1dc 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -529,7 +529,7 @@ function createForumTopic($forum, $container = FALSE) { // Retrieve node object, ensure that the topic was created and in the proper forum. $node = $this->drupalGetNodeByTitle($title); $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title))); - $this->assertEqual($node->taxonomy_forums[Language::LANGCODE_NOT_SPECIFIED][0]['tid'], $tid, 'Saved forum topic was in the expected forum'); + $this->assertEqual($node->taxonomy_forums[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'], $tid, 'Saved forum topic was in the expected forum'); // View forum topic. $this->drupalGet('node/' . $node->nid); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index 9d022c5..6063677 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -87,7 +87,7 @@ public function testForumPager() { 'nid' => NULL, 'type' => 'forum', 'taxonomy_forums' => array( - array('tid' => $tid) + array('target_id' => $tid), ), )); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php index f36fca7..66fc524 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php @@ -111,7 +111,7 @@ public function setUp() { $entity->name->value = $this->randomName(); $index = $i ? 1 : 0; $entity->user_id->target_id = $this->accounts[$index]->uid; - $entity->{$this->fieldName}->tid = $this->terms[$index]->id(); + $entity->{$this->fieldName}->target_id = $this->terms[$index]->id(); $entity->save(); $this->entities[] = $entity; } @@ -153,7 +153,7 @@ public function testQuery() { // This returns the 0th entity as that's only one pointing to the 0th // term (test with specifying the column name). $this->queryResults = $this->factory->get('entity_test') - ->condition("$this->fieldName.tid.entity.name", $this->terms[0]->name->value) + ->condition("$this->fieldName.target_id.entity.name", $this->terms[0]->name->value) ->execute(); $this->assertResults(array(0)); // This returns the 1st and 2nd entity as those point to the 1st term. diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php index 5ad7a44..ba4bca5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php @@ -102,7 +102,7 @@ function setUp() { 'title' => $this->xss_label, 'type' => 'article', 'promote' => NODE_PROMOTED, - 'field_tags' => array(array('tid' => $this->term->id())), + 'field_tags' => array(array('target_id' => $this->term->id())), )); // Create a test comment on the test node. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php index 63dbc0f..b44002e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/LinkFormatter.php @@ -33,9 +33,10 @@ class LinkFormatter extends TaxonomyFormatterBase { public function viewElements(EntityInterface $entity, $langcode, array $items) { $elements = array(); - // Terms without tid do not exist yet, theme such terms as just their name. + // Terms without target_id do not exist yet, theme such terms as just their + // name. foreach ($items as $delta => $item) { - if (!$item['tid']) { + if (!$item['target_id']) { $elements[$delta] = array( '#markup' => check_plain($item['entity']->label()), ); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php index e1cd48d..2a2af05 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/RSSCategoryFormatter.php @@ -31,10 +31,10 @@ class RSSCategoryFormatter extends TaxonomyFormatterBase { * {@inheritdoc} */ public function viewElements(EntityInterface $entity, $langcode, array $items) { - // Terms whose tid is 'autocreate' do not exist yet and $item['entity'] is - // not set. Theme such terms as just their name. + // Terms whose target_id is 'autocreate' do not exist yet and + // $item['entity'] is not set. Theme such terms as just their name. foreach ($items as $item) { - if ($item['tid']) { + if ($item['target_id']) { $value = $item['entity']->label(); $uri = $item['entity']->uri(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php index 6f688da..90f76ad 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/TaxonomyFormatterBase.php @@ -30,8 +30,8 @@ public function prepareView(array $entities, $langcode, array &$items) { foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Force the array key to prevent duplicates. - if ($item['tid'] !== 0) { - $tids[$item['tid']] = $item['tid']; + if ($item['target_id'] !== 0) { + $tids[$item['target_id']] = $item['target_id']; } } } @@ -46,12 +46,12 @@ public function prepareView(array $entities, $langcode, array &$items) { foreach ($items[$id] as $delta => $item) { // Check whether the taxonomy term field instance value could be // loaded. - if (isset($terms[$item['tid']])) { + if (isset($terms[$item['target_id']])) { // Replace the instance value with the term data. - $items[$id][$delta]['entity'] = $terms[$item['tid']]; + $items[$id][$delta]['entity'] = $terms[$item['target_id']]; } // Terms to be created are not in $terms, but are still legitimate. - elseif ($item['tid'] === 0 && isset($item['entity'])) { + elseif ($item['target_id'] === 0 && isset($item['entity'])) { // Leave the item in place. } // Otherwise, unset the instance value, since the term does not exist. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php index c0ef1f6..78f8fb3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/widget/TaxonomyAutocompleteWidget.php @@ -50,7 +50,7 @@ public function settingsForm(array $form, array &$form_state) { public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) { $tags = array(); foreach ($items as $item) { - $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']); + $tags[$item['target_id']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['target_id']); } $element += array( '#type' => 'textfield', @@ -86,7 +86,7 @@ public function massageFormValues(array $values, array $form, array &$form_state // otherwise, create a new term. if ($possibilities = entity_load_multiple_by_properties('taxonomy_term', array('name' => trim($value), 'vid' => array_keys($vocabularies)))) { $term = array_pop($possibilities); - $item = array('tid' => $term->id()); + $item = array('target_id' => $term->id()); } else { $vocabulary = reset($vocabularies); @@ -94,7 +94,7 @@ public function massageFormValues(array $values, array $form, array &$form_state 'vid' => $vocabulary->id(), 'name' => $value, )); - $item = array('tid' => 0, 'entity' => $term); + $item = array('target_id' => 0, 'entity' => $term); } $items[] = $item; } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php index a8aefcb..e9180d6 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php @@ -78,14 +78,14 @@ public function testTaxonomyTermReferenceItem() { $tid = $this->term->id(); // Just being able to create the entity like this verifies a lot of code. $entity = entity_create('entity_test', array()); - $entity->field_test_taxonomy->tid = $this->term->id(); + $entity->field_test_taxonomy->target_id = $this->term->id(); $entity->name->value = $this->randomName(); $entity->save(); $entity = entity_load('entity_test', $entity->id()); $this->assertTrue($entity->field_test_taxonomy instanceof FieldInterface, 'Field implements interface.'); $this->assertTrue($entity->field_test_taxonomy[0] instanceof FieldItemInterface, 'Field item implements interface.'); - $this->assertEqual($entity->field_test_taxonomy->tid, $this->term->id()); + $this->assertEqual($entity->field_test_taxonomy->target_id, $this->term->id()); $this->assertEqual($entity->field_test_taxonomy->entity->name->value, $this->term->name->value); $this->assertEqual($entity->field_test_taxonomy->entity->id(), $tid); $this->assertEqual($entity->field_test_taxonomy->entity->uuid(), $this->term->uuid()); @@ -106,7 +106,7 @@ public function testTaxonomyTermReferenceItem() { )); $term2->save(); - $entity->field_test_taxonomy->tid = $term2->id(); + $entity->field_test_taxonomy->target_id = $term2->id(); $this->assertEqual($entity->field_test_taxonomy->entity->id(), $term2->id()); $this->assertEqual($entity->field_test_taxonomy->entity->name->value, $term2->name->value); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php index 53a53b1..458cf9e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -85,7 +85,7 @@ function testTaxonomyTermFieldValidation() { $langcode = Language::LANGCODE_NOT_SPECIFIED; $entity = entity_create('entity_test', array()); $term = $this->createTerm($this->vocabulary); - $entity->{$this->field_name}->tid = $term->id(); + $entity->{$this->field_name}->target_id = $term->id(); try { field_attach_validate($entity); $this->pass('Correct term does not cause validation error.'); @@ -96,7 +96,7 @@ function testTaxonomyTermFieldValidation() { $entity = entity_create('entity_test', array()); $bad_term = $this->createTerm($this->createVocabulary()); - $entity->{$this->field_name}->tid = $bad_term->id(); + $entity->{$this->field_name}->target_id = $bad_term->id(); try { field_attach_validate($entity); $this->fail('Wrong term causes validation error.'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php index d6280c8..5ef5a97 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php @@ -175,7 +175,7 @@ function testTaxonomyIndex() { $this->assertEqual(1, $index_count, 'Term 2 is indexed once.'); // Update the article to change one term. - $node->{$this->field_name_1}[$langcode] = array(array('tid' => $term_1->id())); + $node->{$this->field_name_1}[$langcode] = array(array('target_id' => $term_1->id())); $node->save(); // Check that both terms are indexed. @@ -191,7 +191,7 @@ function testTaxonomyIndex() { $this->assertEqual(1, $index_count, 'Term 2 is indexed.'); // Update the article to change another term. - $node->{$this->field_name_2}[$langcode] = array(array('tid' => $term_1->id())); + $node->{$this->field_name_2}[$langcode] = array(array('target_id' => $term_1->id())); $node->save(); // Check that only one term is indexed. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php index 74c546b..f8f315b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php @@ -55,8 +55,8 @@ function setUp() { $node = array(); $node['type'] = 'article'; - $node['field_views_testing_tags'][]['tid'] = $this->term1->id(); - $node['field_views_testing_tags'][]['tid'] = $this->term2->id(); + $node['field_views_testing_tags'][]['target_id'] = $this->term1->id(); + $node['field_views_testing_tags'][]['target_id'] = $this->term2->id(); $this->nodes[] = $this->drupalCreateNode($node); $this->nodes[] = $this->drupalCreateNode($node); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php index b558d97..6b9a763 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Type/TaxonomyTermReferenceItem.php @@ -9,11 +9,12 @@ use Drupal\Core\Entity\Field\FieldItemBase; use Drupal\Core\TypedData\TypedDataInterface; +use Drupal\Core\Entity\Field\Type\EntityReferenceItem; /** * Defines the 'taxonomy_term_reference' entity field item. */ -class TaxonomyTermReferenceItem extends FieldItemBase { +class TaxonomyTermReferenceItem extends EntityReferenceItem { /** * Property definitions of the contained properties. @@ -28,40 +29,7 @@ class TaxonomyTermReferenceItem extends FieldItemBase { * Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). */ public function getPropertyDefinitions() { - if (!isset(static::$propertyDefinitions)) { - static::$propertyDefinitions['tid'] = array( - 'type' => 'integer', - 'label' => t('Referenced taxonomy term id.'), - ); - static::$propertyDefinitions['entity'] = array( - 'type' => 'entity', - 'constraints' => array( - 'EntityType' => 'taxonomy_term', - ), - 'label' => t('Term'), - 'description' => t('The referenced taxonomy term'), - // The entity object is computed out of the tid. - 'computed' => TRUE, - 'read-only' => FALSE, - 'settings' => array('id source' => 'tid'), - ); - } - return static::$propertyDefinitions; - } - - /** - * Overrides \Drupal\Core\Entity\Field\FieldItemBase::get(). - */ - public function setValue($values, $notify = TRUE) { - // Treat the values as property value of the entity property, if no array is - // given. - if (isset($values) && !is_array($values)) { - $values = array('entity' => $values); - } - // Make sure that the 'entity' property gets set as 'tid'. - if (isset($values['tid']) && !isset($values['entity'])) { - $values['entity'] = $values['tid']; - } - parent::setValue($values, $notify); + $this->definition['settings']['target_type'] = 'taxonomy_term'; + return parent::getPropertyDefinitions(); } } diff --git a/core/modules/taxonomy/taxonomy.install b/core/modules/taxonomy/taxonomy.install index d89b89c..f579755 100644 --- a/core/modules/taxonomy/taxonomy.install +++ b/core/modules/taxonomy/taxonomy.install @@ -6,6 +6,7 @@ */ use Drupal\Component\Uuid\Uuid; +use Drupal\field\Plugin\Core\Entity\Field; /** * Implements hook_uninstall(). @@ -175,25 +176,37 @@ function taxonomy_schema() { function taxonomy_field_schema($field) { return array( 'columns' => array( - 'tid' => array( + 'target_id' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, ), ), 'indexes' => array( - 'tid' => array('tid'), + 'target_id' => array('target_id'), ), 'foreign keys' => array( - 'tid' => array( + 'target_id' => array( 'table' => 'taxonomy_term_data', - 'columns' => array('tid' => 'tid'), + 'columns' => array('target_id' => 'tid'), ), ), ); } /** + * Implements hook_update_dependencies(). + */ +function taxonomy_update_dependencies() { + // Convert the 'tid' column of the taxonomy reference field to 'target_id' + // after fields and instances have been moved to the config system. + $dependencies['taxonomy'][8007] = array( + 'field' => 8003, + ); + return $dependencies; +} + +/** * Remove the {taxonomy_vocabulary}.module field. */ function taxonomy_update_8000() { @@ -335,3 +348,41 @@ function taxonomy_update_8006() { ->execute(); } } + +/** + * Update taxonomy_term_reference field tables to use target_id instead of tid. + */ +function taxonomy_update_8007() { + foreach (config_get_storage_names_with_prefix('field.field.') as $config_name) { + $field_config = config($config_name); + // Only update taxonomy reference fields that use the default SQL storage. + if ($field_config->get('type') == 'taxonomy_term_reference' && $field_config->get('storage.type') == 'field_sql_storage') { + $field = new Field($field_config->get()); + + $tables = array( + _field_sql_storage_tablename($field), + _field_sql_storage_revision_tablename($field), + ); + + foreach ($tables as $table_name) { + db_change_field($table_name, $field->id() . '_tid', $field->id() . '_target_id', array( + 'description' => 'The ID of the target entity.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + )); + + // Change the index. + db_drop_index($table_name, $field->id() . '_tid'); + db_add_index($table_name, $field->id() . '_target_id', array($field->id() . '_target_id')); + } + + // Update the indexes in field config as well. + $indexes = $field_config->get('indexes'); + unset($indexes['tid']); + $indexes['target_id'] = array('target_id'); + $field_config->set('indexes', $indexes); + $field_config->save(); + } + } +} diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 980ad00..b2c6b83 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -948,8 +948,8 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, $field, $instan // Build an array of existing term IDs so they can be loaded with // taxonomy_term_load_multiple(); foreach ($items as $delta => $item) { - if (!empty($item['tid']) && $item['tid'] != 'autocreate') { - $tids[] = $item['tid']; + if (!empty($item['target_id']) && $item['target_id'] != 'autocreate') { + $tids[] = $item['target_id']; } } if (!empty($tids)) { @@ -959,12 +959,12 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, $field, $instan // allowed values for this field. foreach ($items as $delta => $item) { $validate = TRUE; - if (!empty($item['tid']) && $item['tid'] != 'autocreate') { + if (!empty($item['target_id']) && $item['target_id'] != 'autocreate') { $validate = FALSE; foreach ($field['settings']['allowed_values'] as $settings) { // If no parent is specified, check if the term is in the vocabulary. if (isset($settings['vocabulary']) && empty($settings['parent'])) { - if ($settings['vocabulary'] == $terms[$item['tid']]->bundle()) { + if ($settings['vocabulary'] == $terms[$item['target_id']]->bundle()) { $validate = TRUE; break; } @@ -972,7 +972,7 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, $field, $instan // If a parent is specified, then to validate it must appear in the // array returned by taxonomy_term_load_parents_all(). elseif (!empty($settings['parent'])) { - $ancestors = taxonomy_term_load_parents_all($item['tid']); + $ancestors = taxonomy_term_load_parents_all($item['target_id']); foreach ($ancestors as $ancestor) { if ($ancestor->id() == $settings['parent']) { $validate = TRUE; @@ -996,7 +996,7 @@ function taxonomy_field_validate(EntityInterface $entity = NULL, $field, $instan * Implements hook_field_is_empty(). */ function taxonomy_field_is_empty($item, $field_type) { - return !is_array($item) || (empty($item['tid']) && empty($item['entity'])); + return !is_array($item) || (empty($item['target_id']) && empty($item['entity'])); } /** @@ -1153,10 +1153,9 @@ function taxonomy_rdf_mapping() { */ function taxonomy_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $item) { - if (!$item['tid'] && isset($item['entity'])) { - unset($item['tid']); + if (!$item['target_id'] && isset($item['target_id'])) { $item['entity']->save(); - $items[$delta]['tid'] = $item['entity']->id(); + $items[$delta]['target_id'] = $item['entity']->id(); } } } @@ -1216,7 +1215,7 @@ function taxonomy_build_node_index($node) { foreach (field_available_languages('node', $field) as $langcode) { if (!empty($items[$langcode])) { foreach ($items[$langcode] as $item) { - $tid_all[$item['tid']] = $item['tid']; + $tid_all[$item['target_id']] = $item['target_id']; } } } diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index d52819b..876c6c8 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -346,7 +346,7 @@ function taxonomy_field_views_data($field) { } // Add the relationship only on the tid field. - $data[$table_name][$field['field_name'] . '_tid']['relationship'] = array( + $data[$table_name][$field['field_name'] . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'taxonomy_term_data', 'base field' => 'tid', @@ -380,7 +380,7 @@ function taxonomy_field_views_data_views_data_alter(&$data, $field) { 'id' => 'entity_reverse', 'field_name' => $field['field_name'], 'field table' => _field_sql_storage_tablename($field), - 'field field' => $field['field_name'] . '_tid', + 'field field' => $field['field_name'] . '_target_id', 'base' => $entity_info['base_table'], 'base field' => $entity_info['entity_keys']['id'], 'label' => t('!field_name', array('!field_name' => $field['field_name'])), diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 9cfdce9..9df7c23 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -89,7 +89,7 @@ protected function setUp() { $term = $this->createTerm($this->vocabulary); $values = array('created' => $time, 'type' => 'page'); - $values[$this->field_name][]['tid'] = $term->id(); + $values[$this->field_name][]['target_id'] = $term->id(); // Make every other node promoted. if ($i % 2) { diff --git a/core/profiles/standard/config/field.field.field_tags.yml b/core/profiles/standard/config/field.field.field_tags.yml index eaa1971..e0f6952 100644 --- a/core/profiles/standard/config/field.field.field_tags.yml +++ b/core/profiles/standard/config/field.field.field_tags.yml @@ -17,7 +17,7 @@ cardinality: '-1' translatable: '0' entity_types: { } indexes: - tid: - - tid + target_id: + - target_id status: 1 langcode: und