diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index e18edbd..ce53873 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -96,9 +96,13 @@ public function __construct($entityType) { */ public function create(array $values) { // We have to determine the bundle first. - // @todo Throw an exception if no bundle is passed and we have a bundle key - // defined. - $bundle = $this->bundleKey ? $values[$this->bundleKey] : FALSE; + $bundle = FALSE; + if ($this->bundleKey) { + if (!isset($values[$this->bundleKey])) { + throw new EntityStorageException(t('Missing bundle for entity type @type', array('@type' => $this->entityType))); + } + $bundle = $values[$this->bundleKey]; + } $entity = new $this->entityClass(array(), $this->entityType, $bundle); // Set all other given values. diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php index 70961b0..e1b913c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php @@ -90,31 +90,31 @@ function testTermAutocompletion() { // We should get both terms in a JSON encoded string. $input = '10/'; $data = $this->drupalGetAJAX($path_prefix_single, array('query' => array('q' => $input))); - $this->assertEqual(strip_tags($data[$first_term->name. ' (1)']), check_plain($first_term->name), 'Autocomplete returned the first matching term'); - $this->assertEqual(strip_tags($data[$second_term->name. ' (2)']), check_plain($second_term->name), 'Autocomplete returned the second matching term'); + $this->assertEqual(strip_tags($data[$first_term->label(). ' (1)']), check_plain($first_term->label()), 'Autocomplete returned the first matching term'); + $this->assertEqual(strip_tags($data[$second_term->label(). ' (2)']), check_plain($second_term->label()), 'Autocomplete returned the second matching term'); // Try to autocomplete a term name that matches the first term. // We should only get the first term in a JSON encoded string. $input = '10/16'; $this->drupalGet($path_prefix_single, array('query' => array('q' => $input))); - $target = array($first_term->name . ' (1)' => '
' . check_plain($first_term->name) . '
'); + $target = array($first_term->label() . ' (1)' => '
' . check_plain($first_term->label()) . '
'); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.'); // Try to autocomplete a term name that matches the second term, and the // first term is already typed in the autocomplete (tags) widget. - $input = $first_term->name . ' (1), 10/17'; + $input = $first_term->label() . ' (1), 10/17'; $data = $this->drupalGetAJAX($path_prefix_tags, array('query' => array('q' => $input))); - $this->assertEqual(strip_tags($data[$first_term->name . ' (1), ' . $second_term->name . ' (2)']), check_plain($second_term->name), 'Autocomplete returned the second matching term'); + $this->assertEqual(strip_tags($data[$first_term->label() . ' (1), ' . $second_term->label() . ' (2)']), check_plain($second_term->label()), 'Autocomplete returned the second matching term'); // Try to autocomplete a term name with both a comma and a slash. $input = '"term with, comma and / a'; $this->drupalGet($path_prefix_single, array('query' => array('q' => $input))); $n = $third_term->name; // Term names containing commas or quotes must be wrapped in quotes. - if (strpos($third_term->name, ',') !== FALSE || strpos($third_term->name, '"') !== FALSE) { - $n = '"' . str_replace('"', '""', $third_term->name) . ' (3)"'; + if (strpos($third_term->label(), ',') !== FALSE || strpos($third_term->label(), '"') !== FALSE) { + $n = '"' . str_replace('"', '""', $third_term->label()) . ' (3)"'; } - $target = array($n => '
' . check_plain($third_term->name) . '
'); + $target = array($n => '
' . check_plain($third_term->label()) . '
'); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns a term containing a comma and a slash.'); } } diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc index 0403fb1..92ebc29 100644 --- a/core/modules/forum/forum.admin.inc +++ b/core/modules/forum/forum.admin.inc @@ -5,31 +5,37 @@ * Administrative page callbacks for the Forum module. */ +use Drupal\taxonomy\Plugin\Core\Entity\Term; + /** * Page callback: Returns a form for creating a new forum or container. * * @param $type * What is being added. Possible values are 'forum' and 'container'. - * @param $edit - * (optional) Associative array containing a forum term to be edited. - * Defaults to an empty array. + * @param \Drupal\taxonomy\Plugin\Core\Entity\Term $term + * (optional) A forum or container term to be + * edited. Defaults to NULL * * @return * A form for creating a new forum or container. * * @see forum_menu() */ -function forum_form_main($type, $edit = array()) { - $edit = (array) $edit; +function forum_form_main($type, Term $term = NULL) { if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || !empty($_POST['confirm'])) { - return drupal_get_form('forum_confirm_delete', $edit['tid']); + return drupal_get_form('forum_confirm_delete', $term->id()); + } + + if (!$term) { + $term = entity_create('taxonomy_term', array('vid' => config('forum.settings')->get('vocabulary'))); } + switch ($type) { case 'forum': - return drupal_get_form('forum_form_forum', $edit); + return drupal_get_form('forum_form_forum', $term); break; case 'container': - return drupal_get_form('forum_form_container', $edit); + return drupal_get_form('forum_form_container', $term); break; } } @@ -37,46 +43,39 @@ function forum_form_main($type, $edit = array()) { /** * Form constructor for adding and editing a forum. * - * @param $edit - * (optional) Associative array containing a forum term to be added or edited. - * Defaults to an empty array. + * @param \Drupal\taxonomy\Plugin\Core\Entity\Term $term + * A forum term to be edited. * * @see forum_form_submit() * @ingroup forms */ -function forum_form_forum($form, &$form_state, $edit = array()) { - $edit += array( - 'name' => '', - 'description' => '', - 'tid' => NULL, - 'weight' => 0, - ); +function forum_form_forum($form, &$form_state, Term $term) { $form['name'] = array('#type' => 'textfield', '#title' => t('Forum name'), - '#default_value' => $edit['name'], + '#default_value' => $term->name->value, '#maxlength' => 255, '#description' => t('Short but meaningful name for this collection of threaded discussions.'), '#required' => TRUE, ); $form['description'] = array('#type' => 'textarea', '#title' => t('Description'), - '#default_value' => $edit['description'], + '#default_value' => $term->description->value, '#description' => t('Description and guidelines for discussions within this forum.'), ); $form['parent']['#tree'] = TRUE; - $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'forum'); + $form['parent'][0] = _forum_parent_select($term->id(), t('Parent'), 'forum'); $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), - '#default_value' => $edit['weight'], + '#default_value' => $term->weight->value, '#description' => t('Forums are displayed in ascending order by weight (forums with equal weights are displayed alphabetically).'), ); $form['vid'] = array('#type' => 'hidden', '#value' => config('forum.settings')->get('vocabulary')); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#button_type' => 'primary'); - if ($edit['tid']) { + if (!$term->isNew()) { $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete')); - $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']); + $form['tid'] = array('#type' => 'hidden', '#value' => $term->id()); } $form['#submit'][] = 'forum_form_submit'; $form['#theme'] = 'forum_form'; @@ -140,26 +139,19 @@ function theme_forum_form($variables) { /** * Form constructor for adding and editing forum containers. * - * @param $edit - * (optional) Associative array containing a container term to be added or edited. - * Defaults to an empty array. + * @param \Drupal\taxonomy\Plugin\Core\Entity\Term $term + * A container term to be edited. * * @see forum_form_submit() * @ingroup forms */ -function forum_form_container($form, &$form_state, $edit = array()) { +function forum_form_container($form, &$form_state, Term $term) { $config = config('forum.settings'); - $edit += array( - 'name' => '', - 'description' => '', - 'tid' => NULL, - 'weight' => 0, - ); // Handle a delete operation. $form['name'] = array( '#title' => t('Container name'), '#type' => 'textfield', - '#default_value' => $edit['name'], + '#default_value' => $term->name->value, '#maxlength' => 255, '#description' => t('Short but meaningful name for this collection of related forums.'), '#required' => TRUE @@ -168,15 +160,15 @@ function forum_form_container($form, &$form_state, $edit = array()) { $form['description'] = array( '#type' => 'textarea', '#title' => t('Description'), - '#default_value' => $edit['description'], + '#default_value' => $term->description->value, '#description' => t('Description and guidelines for forums within this container.') ); $form['parent']['#tree'] = TRUE; - $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'container'); + $form['parent'][0] = _forum_parent_select($term->id(), t('Parent'), 'container'); $form['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), - '#default_value' => $edit['weight'], + '#default_value' => $term->weight->value, '#description' => t('Containers are displayed in ascending order by weight (containers with equal weights are displayed alphabetically).') ); @@ -190,9 +182,9 @@ function forum_form_container($form, &$form_state, $edit = array()) { '#value' => t('Save'), '#button_type' => 'primary', ); - if ($edit['tid']) { + if (!$term->isNew()) { $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete')); - $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']); + $form['tid'] = array('#type' => 'value', '#value' => $term->id()); } $form['#submit'][] = 'forum_form_submit'; $form['#theme'] = 'forum_form'; @@ -295,15 +287,15 @@ function forum_overview($form, &$form_state) { foreach (element_children($form) as $key) { if (isset($form[$key]['#term'])) { $term = $form[$key]['#term']; - $form[$key]['view']['#href'] = 'forum/' . $term['tid']; + $form[$key]['view']['#href'] = 'forum/' . $term->id(); unset($form[$key]['operations']['#links']['delete']); - if (in_array($form[$key]['#term']['tid'], $config->get('containers'))) { + if (in_array($term->id(), $config->get('containers'))) { $form[$key]['operations']['#links']['edit']['title'] = t('edit container'); - $form[$key]['operations']['#links']['edit']['href'] = 'admin/structure/forum/edit/container/' . $term['tid']; + $form[$key]['operations']['#links']['edit']['href'] = 'admin/structure/forum/edit/container/' . $term->id(); } else { $form[$key]['operations']['#links']['edit']['title'] = t('edit forum'); - $form[$key]['operations']['#links']['edit']['href'] = 'admin/structure/forum/edit/forum/' . $term['tid']; + $form[$key]['operations']['#links']['edit']['href'] = 'admin/structure/forum/edit/forum/' . $term->id(); } } } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 952e98f..0bde79f 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -432,7 +432,7 @@ function forum_node_load($nodes) { ->condition('f.vid', $node_vids); $result = $query->execute(); foreach ($result as $record) { - $nodes[$record->nid]->forum_tid = $record->id(); + $nodes[$record->nid]->forum_tid = $record->tid; } } } @@ -526,7 +526,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->id(), + 'tid' => $translation->taxonomy_forums->tid, 'sticky' => $entity->sticky, 'created' => $entity->created, 'comment_count' => 0, @@ -713,6 +713,7 @@ function forum_forum_load($tid = NULL) { elseif ($tid === 0) { $forum_term = entity_create('taxonomy_term', array( 'tid' => 0, + 'vid' => $vid, )); } @@ -1045,8 +1046,8 @@ function template_preprocess_forum_list(&$variables) { $row = 0; // Sanitize each forum so that the template can safely print the data. foreach ($variables['forums'] as $id => $forum) { - $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : ''; - $variables['forums'][$id]->link = url("forum/$forum->id()"); + $variables['forums'][$id]->description = check_markup($forum->description->value, $forum->format->value); + $variables['forums'][$id]->link = url('forum/' . $forum->id()); $variables['forums'][$id]->name = check_plain($forum->label()); $variables['forums'][$id]->is_container = !empty($forum->container); $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; @@ -1061,8 +1062,8 @@ function template_preprocess_forum_list(&$variables) { if ($user->uid) { $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->id(), $user->uid); if ($variables['forums'][$id]->new_topics) { - $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new post in forum %title', '@count new posts in forum %title', array('%title' => $variables['forums'][$id]->name)); - $variables['forums'][$id]->new_url = url("forum/$forum->id()", array('fragment' => 'new')); + $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new post in forum %title', '@count new posts in forum %title', array('%title' => $variables['forums'][$id]->label())); + $variables['forums'][$id]->new_url = url('forum/' . $forum->id(), array('fragment' => 'new')); $variables['forums'][$id]->icon_class = 'new'; $variables['forums'][$id]->icon_title = t('New posts'); } diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index d0c7c9b..290b257 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -241,9 +241,7 @@ function testAddOrphanTopic() { // Must remove forum topics to test creating orphan topics. $vid = config('forum.settings')->get('vocabulary'); $tree = taxonomy_get_tree($vid); - foreach ($tree as $term) { - taxonomy_term_delete($term->id()); - } + taxonomy_term_delete_multiple(array_keys(taxonomy_term_load_multiple(NULL))); // Create an orphan forum item. $this->drupalLogin($this->admin_user); diff --git a/core/modules/forum/templates/forum-list.tpl.php b/core/modules/forum/templates/forum-list.tpl.php index b169493..da8a12d 100644 --- a/core/modules/forum/templates/forum-list.tpl.php +++ b/core/modules/forum/templates/forum-list.tpl.php @@ -55,8 +55,8 @@ icon_title; ?>
label(); ?>
- description): ?> -
description; ?>
+ description->value): ?> +
description->value; ?>
', $forum->depth); ?> diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index f9789a0..a9ae1c3 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -77,7 +77,7 @@ public function testForumPager() { // Look up the general discussion term. $tree = taxonomy_get_tree($vid, 0, 1); - $tid = reset($tree)->id(); + $tid = reset($tree)->tid; $this->assertTrue($tid, 'General discussion term is found in the forum vocabulary.'); // Create 30 nodes. 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 1216760..c2b0186 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php @@ -147,18 +147,18 @@ public function testQuery() { // This returns the 0th entity as that's only one pointing to the 0th // term (test without specifying the field column). $this->queryResults = $this->factory->get('entity_test') - ->condition("$this->fieldName.entity.name", $this->terms[0]->name) + ->condition("$this->fieldName.entity.name", $this->terms[0]->name->value) ->execute(); $this->assertResults(array(0)); // 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) + ->condition("$this->fieldName.tid.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. $this->queryResults = $this->factory->get('entity_test') - ->condition("$this->fieldName.entity.name", $this->terms[0]->name, '<>') + ->condition("$this->fieldName.entity.name", $this->terms[0]->name->value, '<>') ->execute(); $this->assertResults(array(1, 2)); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index 358d834..bdb6cd2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -352,7 +352,7 @@ function testBreadCrumbs() { $tree += array( $link['link_path'] => $link['link_title'], ); - $this->assertBreadcrumb($link['link_path'], $trail, $term->name, $tree); + $this->assertBreadcrumb($link['link_path'], $trail, $term->label(), $tree); $this->assertRaw(check_plain($parent->title), 'Tagged node found.'); // Additionally make sure that this link appears only once; i.e., the @@ -368,7 +368,7 @@ function testBreadCrumbs() { // Next iteration should expect this tag as parent link. // Note: Term name, not link name, due to taxonomy_term_page(). $trail += array( - $link['link_path'] => $term->name, + $link['link_path'] => $term->label(), ); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php index b987739..6b53b22 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php @@ -69,15 +69,14 @@ function testUrlAlter() { $this->assertUrlOutboundAlter('forum', 'community'); $forum_vid = config('forum.settings')->get('vocabulary'); $term_name = $this->randomName(); - $tid = db_insert('taxonomy_term_data') - ->fields(array( - 'name' => $term_name, - 'vid' => $forum_vid, - )) - ->execute(); - $this->drupalGet("community/$tid"); + $term = entity_create('taxonomy_term', array( + 'name' => $term_name, + 'vid' => $forum_vid, + )); + $term->save(); + $this->drupalGet("community/" . $term->id()); $this->assertText($term_name, 'The community/{tid} path gets resolved correctly'); - $this->assertUrlOutboundAlter("forum/$tid", "community/$tid"); + $this->assertUrlOutboundAlter("forum/" . $term->id(), "community/" . $term->id()); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php index c43c69e..6cdfa9b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php @@ -152,7 +152,7 @@ public function query($group_by = FALSE) { function title() { $term = taxonomy_term_load($this->argument); if (!empty($term)) { - return check_plain($term->name); + return check_plain($term->label()); } // TODO review text return t('No name'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/Taxonomy.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/Taxonomy.php index 3106222..70f84bf 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/Taxonomy.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/Taxonomy.php @@ -30,7 +30,7 @@ function title() { if ($this->argument) { $term = taxonomy_term_load($this->argument); if (!empty($term)) { - return check_plain($term->name); + return check_plain($term->label()); } } // TODO review text diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php index 0dbcd4c..fafe15d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/Term.php @@ -109,7 +109,7 @@ function validate_argument($argument) { if (!$term) { return FALSE; } - $this->argument->validated_title = check_plain($term->name); + $this->argument->validated_title = check_plain($term->label()); return empty($vocabularies) || !empty($vocabularies[$term->bundle()]); case 'tids': @@ -151,7 +151,7 @@ function validate_argument($argument) { return FALSE; } - $titles[] = $validated_cache[$term->id()] = check_plain($term->name); + $titles[] = $validated_cache[$term->id()] = check_plain($term->label()); unset($test[$term->id()]); } } @@ -175,7 +175,7 @@ function validate_argument($argument) { if ($type == 'convert') { $this->argument->argument = $term->id(); } - $this->argument->validated_title = check_plain($term->name); + $this->argument->validated_title = check_plain($term->label()); return TRUE; } return FALSE; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php index 4299de7..18f458b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/TaxonomyIndexTid.php @@ -120,7 +120,7 @@ function pre_render(&$values) { $result = $query->execute(); foreach ($result as $term) { - $this->items[$term->node_nid][$term->id()]['name'] = check_plain($term->name); + $this->items[$term->node_nid][$term->id()]['name'] = check_plain($term->label()); $this->items[$term->node_nid][$term->id()]['tid'] = $term->id(); $this->items[$term->node_nid][$term->id()]['vocabulary_vid'] = $term->bundle(); $this->items[$term->node_nid][$term->id()]['vocabulary'] = check_plain($vocabularies[$term->bundle()]->label()); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php index 73e2947..b5690c0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermStorageController.php @@ -93,7 +93,7 @@ protected function postSave(EntityInterface $entity, $update) { foreach ($entity->parent as $parent) { $query->values(array( 'tid' => $entity->id(), - 'parent' => $parent->value, + 'parent' => (int)$parent->value, )); } $query->execute(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php index ab36a79..0d4fcc5 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php @@ -8,12 +8,12 @@ namespace Drupal\taxonomy; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\EntityTranslationController; +use Drupal\translation_entity\EntityTranslationControllerNG; /** * Defines the translation controller class for terms. */ -class TermTranslationController extends EntityTranslationController { +class TermTranslationController extends EntityTranslationControllerNG { /** * Overrides EntityTranslationController::entityFormAlter(). diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php index b1c5421..ff75e2b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php @@ -73,7 +73,6 @@ function setUp() { function testTaxonomyRss() { // Create two taxonomy terms. $term1 = $this->createTerm($this->vocabulary); - debug($term1->getPropertyValues()); // RSS display must be added manually. $this->drupalGet("admin/structure/types/manage/article/display"); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 1bf0051..6a50b11 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -115,25 +115,25 @@ function testTaxonomyNode() { // Check that the term is displayed when the node is viewed. $node = $this->drupalGetNodeByTitle($edit["title"]); $this->drupalGet('node/' . $node->nid); - $this->assertText($term1->name, 'Term is displayed when viewing the node.'); + $this->assertText($term1->label(), 'Term is displayed when viewing the node.'); $this->clickLink(t('Edit')); - $this->assertText($term1->name, 'Term is displayed when editing the node.'); + $this->assertText($term1->label(), 'Term is displayed when editing the node.'); $this->drupalPost(NULL, array(), t('Save')); - $this->assertText($term1->name, 'Term is displayed after saving the node with no changes.'); + $this->assertText($term1->label(), 'Term is displayed after saving the node with no changes.'); // Edit the node with a different term. $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term2->id(); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->nid); - $this->assertText($term2->name, 'Term is displayed when viewing the node.'); + $this->assertText($term2->label(), 'Term is displayed when viewing the node.'); // Preview the node. $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Preview')); - $this->assertNoUniqueText($term2->name, 'Term is displayed when previewing the node.'); + $this->assertNoUniqueText($term2->label(), 'Term is displayed when previewing the node.'); $this->drupalPost(NULL, NULL, t('Preview')); - $this->assertNoUniqueText($term2->name, 'Term is displayed when previewing the node again.'); + $this->assertNoUniqueText($term2->label(), 'Term is displayed when previewing the node again.'); } /** @@ -199,29 +199,29 @@ function testNodeTermCreationAndDeletion() { // Delete term 2 from the term delete page. $this->drupalPost('taxonomy/term/' . $term_objects['term2']->id() . '/delete', array(), t('Delete')); - $term_names = array($term_objects['term3']->name, $term_objects['term4']->name); + $term_names = array($term_objects['term3']->label(), $term_objects['term4']->label()); // Get the node. $node = $this->drupalGetNodeByTitle($edit["title"]); $this->drupalGet('node/' . $node->nid); foreach ($term_names as $term_name) { - $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted', array('%name' => $term_name, '%deleted1' => $term_objects['term1']->name, '%deleted2' => $term_objects['term2']->name))); + $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted', array('%name' => $term_name, '%deleted1' => $term_objects['term1']->label(), '%deleted2' => $term_objects['term2']->label()))); } - $this->assertNoText($term_objects['term1']->name, format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term1']->name))); - $this->assertNoText($term_objects['term2']->name, format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term2']->name))); + $this->assertNoText($term_objects['term1']->label(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term1']->label()))); + $this->assertNoText($term_objects['term2']->label(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term2']->label()))); // Test autocomplete on term 3, which contains a comma. // The term will be quoted, and the " will be encoded in unicode (\u0022). - $input = substr($term_objects['term3']->name, 0, 3); + $input = substr($term_objects['term3']->label(), 0, 3); $json = $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(), array('query' => array('q' => $input))); - $this->assertEqual($json, '{"\u0022' . $term_objects['term3']->name . '\u0022":"' . $term_objects['term3']->name . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term3']->name))); + $this->assertEqual($json, '{"\u0022' . $term_objects['term3']->label() . '\u0022":"' . $term_objects['term3']->label() . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term3']->label()))); // Test autocomplete on term 4 - it is alphanumeric only, so no extra // quoting. - $input = substr($term_objects['term4']->name, 0, 3); + $input = substr($term_objects['term4']->label(), 0, 3); $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(), array('query' => array('q' => $input))); - $this->assertRaw('{"' . $term_objects['term4']->name . '":"' . $term_objects['term4']->name . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term4']->name))); + $this->assertRaw('{"' . $term_objects['term4']->label() . '":"' . $term_objects['term4']->label() . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term4']->label()))); // Test taxonomy autocomplete with a nonexistent field. $field_name = $this->randomName(); @@ -256,27 +256,27 @@ function testTermAutocompletion() { // The result order is not guaranteed, so check each term separately. $result = $this->drupalGet($path, array('query' => array('q' => $input))); $data = drupal_json_decode($result); - $this->assertEqual($data[$first_term->name], check_plain($first_term->name), 'Autocomplete returned the first matching term'); - $this->assertEqual($data[$second_term->name], check_plain($second_term->name), 'Autocomplete returned the second matching term'); + $this->assertEqual($data[$first_term->label()], check_plain($first_term->label()), 'Autocomplete returned the first matching term'); + $this->assertEqual($data[$second_term->label()], check_plain($second_term->label()), 'Autocomplete returned the second matching term'); // Try to autocomplete a term name that matches first term. // We should only get the first term in a json encoded string. $input = '10/16'; $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(); $this->drupalGet($path, array('query' => array('q' => $input))); - $target = array($first_term->name => check_plain($first_term->name)); + $target = array($first_term->label() => check_plain($first_term->label())); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.'); // Try to autocomplete a term name with both a comma and a slash. $input = '"term with, comma and / a'; $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(); $this->drupalGet($path, array('query' => array('q' => $input))); - $n = $third_term->name; + $n = $third_term->label(); // Term names containing commas or quotes must be wrapped in quotes. - if (strpos($third_term->name, ',') !== FALSE || strpos($third_term->name, '"') !== FALSE) { - $n = '"' . str_replace('"', '""', $third_term->name) . '"'; + if (strpos($third_term->label(), ',') !== FALSE || strpos($third_term->label(), '"') !== FALSE) { + $n = '"' . str_replace('"', '""', $third_term->label()) . '"'; } - $target = array($n => check_plain($third_term->name)); + $target = array($n => check_plain($third_term->label())); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns a term containing a comma and a slash.'); } @@ -365,7 +365,7 @@ function testTermReorder() { drupal_static_reset('taxonomy_get_tree'); drupal_static_reset('taxonomy_get_treeparent'); drupal_static_reset('taxonomy_get_treeterms'); - list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->id()); + list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->id(), 0, NULL, TRUE); $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->id()); @@ -392,7 +392,7 @@ function testTermReorder() { drupal_static_reset('taxonomy_get_tree'); drupal_static_reset('taxonomy_get_treeparent'); drupal_static_reset('taxonomy_get_treeterms'); - $terms = taxonomy_get_tree($this->vocabulary->id()); + $terms = taxonomy_get_tree($this->vocabulary->id(), 0, NULL, TRUE); $this->assertEqual($terms[0]->id(), $term2->id(), 'Term 2 was moved above term 1.'); $this->assertEqual($terms[1]->parents, array($term2->id()), 'Term 3 was made a child of term 2.'); $this->assertEqual($terms[2]->id(), $term1->id(), 'Term 1 was moved below term 2.'); @@ -404,7 +404,7 @@ function testTermReorder() { drupal_static_reset('taxonomy_get_tree'); drupal_static_reset('taxonomy_get_treeparent'); drupal_static_reset('taxonomy_get_treeterms'); - $terms = taxonomy_get_tree($this->vocabulary->id()); + $terms = taxonomy_get_tree($this->vocabulary->id(), 0, NULL, TRUE); $this->assertEqual($terms[0]->id(), $term1->id(), 'Term 1 was moved to back above term 2.'); $this->assertEqual($terms[1]->id(), $term2->id(), 'Term 2 was moved to back below term 1.'); $this->assertEqual($terms[2]->id(), $term3->id(), 'Term 3 is still below term 2.'); @@ -431,8 +431,8 @@ function testTermMultipleParentsInterface() { $terms = taxonomy_term_load_multiple_by_name($edit['name']); $term = reset($terms); $this->assertNotNull($term, 'Term found in database.'); - $this->assertEqual($edit['name'], $term->name, 'Term name was successfully saved.'); - $this->assertEqual($edit['description[value]'], $term->description, 'Term description was successfully saved.'); + $this->assertEqual($edit['name'], $term->label(), 'Term name was successfully saved.'); + $this->assertEqual($edit['description[value]'], $term->description->value, 'Term description was successfully saved.'); // Check that the parent tid is still there. The other parent () is // not added by taxonomy_term_load_parents(). $parents = taxonomy_term_load_parents($term->id()); @@ -447,19 +447,19 @@ function testTaxonomyGetTermByName() { $term = $this->createTerm($this->vocabulary); // Load the term with the exact name. - $terms = taxonomy_term_load_multiple_by_name($term->name); + $terms = taxonomy_term_load_multiple_by_name($term->label()); $this->assertTrue(isset($terms[$term->id()]), 'Term loaded using exact name.'); // Load the term with space concatenated. - $terms = taxonomy_term_load_multiple_by_name(' ' . $term->name . ' '); + $terms = taxonomy_term_load_multiple_by_name(' ' . $term->label() . ' '); $this->assertTrue(isset($terms[$term->id()]), 'Term loaded with extra whitespace.'); // Load the term with name uppercased. - $terms = taxonomy_term_load_multiple_by_name(strtoupper($term->name)); + $terms = taxonomy_term_load_multiple_by_name(strtoupper($term->label())); $this->assertTrue(isset($terms[$term->id()]), 'Term loaded with uppercased name.'); // Load the term with name lowercased. - $terms = taxonomy_term_load_multiple_by_name(strtolower($term->name)); + $terms = taxonomy_term_load_multiple_by_name(strtolower($term->label())); $this->assertTrue(isset($terms[$term->id()]), 'Term loaded with lowercased name.'); // Try to load an invalid term name. @@ -467,23 +467,23 @@ function testTaxonomyGetTermByName() { $this->assertFalse($terms); // Try to load the term using a substring of the name. - $terms = taxonomy_term_load_multiple_by_name(drupal_substr($term->name, 2)); + $terms = taxonomy_term_load_multiple_by_name(drupal_substr($term->label(), 2)); $this->assertFalse($terms); // Create a new term in a different vocabulary with the same name. $new_vocabulary = $this->createVocabulary(); $new_term = entity_create('taxonomy_term', array( - 'name' => $term->name, + 'name' => $term->label(), 'vid' => $new_vocabulary->id(), )); taxonomy_term_save($new_term); // Load multiple terms with the same name. - $terms = taxonomy_term_load_multiple_by_name($term->name); + $terms = taxonomy_term_load_multiple_by_name($term->label()); $this->assertEqual(count($terms), 2, 'Two terms loaded with the same name.'); // Load single term when restricted to one vocabulary. - $terms = taxonomy_term_load_multiple_by_name($term->name, $this->vocabulary->id()); + $terms = taxonomy_term_load_multiple_by_name($term->label(), $this->vocabulary->id()); $this->assertEqual(count($terms), 1, 'One term loaded when restricted by vocabulary.'); $this->assertTrue(isset($terms[$term->id()]), 'Term loaded using exact name and vocabulary machine name.'); @@ -492,11 +492,11 @@ function testTaxonomyGetTermByName() { // Try to load a term by name that doesn't exist in this vocabulary but // exists in another vocabulary. - $terms = taxonomy_term_load_multiple_by_name($term2->name, $new_vocabulary->id()); + $terms = taxonomy_term_load_multiple_by_name($term2->label(), $new_vocabulary->id()); $this->assertFalse($terms, 'Invalid term name restricted by vocabulary machine name not loaded.'); // Try to load terms filtering by a non-existing vocabulary. - $terms = taxonomy_term_load_multiple_by_name($term2->name, 'non_existing_vocabulary'); + $terms = taxonomy_term_load_multiple_by_name($term2->label(), 'non_existing_vocabulary'); $this->assertEqual(count($terms), 0, 'No terms loaded when restricted by a non-existing vocabulary.'); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index daaeb91..566b19e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -116,9 +116,9 @@ function testTaxonomyTokenReplacement() { } // Generate and test unsanitized tokens. - $tests['[term:name]'] = $term2->name; - $tests['[term:description]'] = $term2->description; - $tests['[term:parent:name]'] = $term1->name; + $tests['[term:name]'] = $term2->name->value; + $tests['[term:description]'] = $term2->description->value; + $tests['[term:parent:name]'] = $term1->name->value; $tests['[term:vocabulary:name]'] = $this->vocabulary->name; foreach ($tests as $input => $expected) { diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index c74a5ff..5bb393b 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -253,14 +253,8 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { $destination = drupal_get_destination(); // Build the actual form. foreach ($current_page as $key => $term) { - // Save the term for the current page so we don't have to load it a second time. - $form[$key]['#term'] = (array) $term; - if (isset($term->parents)) { - $form[$key]['#term']['parent'] = $term->parent = $term->parents[0]; - unset($form[$key]['#term']['parents'], $term->parents); - } - - $form[$key]['view'] = array('#type' => 'link', '#title' => $term->label(), '#href' => "taxonomy/term/$term->id()"); + $form[$key]['#term'] = $term; + $form[$key]['view'] = array('#type' => 'link', '#title' => $term->label(), '#href' => "taxonomy/term/" . $term->id()); if ($vocabulary->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE && count($tree) > 1) { $form['#parent_fields'] = TRUE; $form[$key]['tid'] = array( @@ -270,7 +264,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { $form[$key]['parent'] = array( '#type' => 'hidden', // Yes, default_value on a hidden. It needs to be changeable by the javascript. - '#default_value' => $term->parent, + '#default_value' => $term->parent->value, ); $form[$key]['depth'] = array( '#type' => 'hidden', @@ -282,7 +276,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { '#delta' => $delta, '#title_display' => 'invisible', '#title' => t('Weight for added term'), - '#default_value' => $term->weight, + '#default_value' => $term->weight->value, ); } $operations = array( @@ -361,7 +355,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) { $hierarchy = TAXONOMY_HIERARCHY_DISABLED; $changed_terms = array(); - $tree = taxonomy_get_tree($vocabulary->id()); + $tree = taxonomy_get_tree($vocabulary->id(), 0, NULL, TRUE); if (empty($tree)) { return; @@ -369,16 +363,15 @@ function taxonomy_overview_terms_submit($form, &$form_state) { // Build a list of all terms that need to be updated on previous pages. $weight = 0; - $term = (array) $tree[0]; - while ($term['tid'] != $form['#first_tid']) { - if ($term['parents'][0] == 0 && $term['weight'] != $weight) { - $term['parent'] = $term['parents'][0]; - $term['weight'] = $weight; - $changed_terms[$term['tid']] = $term; + $term = $tree[0]; + while ($term->id() != $form['#first_tid']) { + if ($term->parent->value == 0 && $term->weight->value != $weight) { + $term->weight->value = $weight; + $changed_terms[$term->id()] = $term; } $weight++; - $hierarchy = $term['parents'][0] != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; - $term = (array) $tree[$weight]; + $hierarchy = $term->parent->value != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; + $term = $tree[$weight]; } // Renumber the current page weights and assign any new parents. @@ -387,24 +380,24 @@ function taxonomy_overview_terms_submit($form, &$form_state) { if (isset($form[$tid]['#term'])) { $term = $form[$tid]['#term']; // Give terms at the root level a weight in sequence with terms on previous pages. - if ($values['parent'] == 0 && $term['weight'] != $weight) { - $term['weight'] = $weight; - $changed_terms[$term['tid']] = $term; + if ($values['parent'] == 0 && $term->weight->value != $weight) { + $term->weight->value = $weight; + $changed_terms[$term->id()] = $term; } // Terms not at the root level can safely start from 0 because they're all on this page. elseif ($values['parent'] > 0) { $level_weights[$values['parent']] = isset($level_weights[$values['parent']]) ? $level_weights[$values['parent']] + 1 : 0; - if ($level_weights[$values['parent']] != $term['weight']) { - $term['weight'] = $level_weights[$values['parent']]; - $changed_terms[$term['tid']] = $term; + if ($level_weights[$values['parent']] != $term->weight->value) { + $term->weight->value = $level_weights[$values['parent']]; + $changed_terms[$term->id()] = $term; } } // Update any changed parents. - if ($values['parent'] != $term['parent']) { - $term['parent'] = $values['parent']; - $changed_terms[$term['tid']] = $term; + if ($values['parent'] != $term->parent->value) { + $term->parent->value = $values['parent']; + $changed_terms[$term->id()] = $term; } - $hierarchy = $term['parent'] != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; + $hierarchy = $term->parent->value != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; $weight++; } } @@ -412,28 +405,17 @@ function taxonomy_overview_terms_submit($form, &$form_state) { // Build a list of all terms that need to be updated on following pages. for ($weight; $weight < count($tree); $weight++) { $term = (array) $tree[$weight]; - if ($term['parents'][0] == 0 && $term['weight'] != $weight) { - $term['parent'] = $term['parents'][0]; - $term['weight'] = $weight; - $changed_terms[$term['tid']] = $term; + if ($term->parents->value == 0 && $term->weight->value != $weight) { + $term->parent->value = $term->parent->value; + $term->weight->value = $weight; + $changed_terms[$term->id()] = $term; } - $hierarchy = $term['parents'][0] != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; + $hierarchy = $term->parent->value != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; } // Save all updated terms. - foreach ($changed_terms as $changed) { - $term = (object) $changed; - // Update term_hierachy and term_data directly since we don't have a - // fully populated term object to save. - db_update('taxonomy_term_hierarchy') - ->fields(array('parent' => $term->parent)) - ->condition('tid', $term->id(), '=') - ->execute(); - - db_update('taxonomy_term_data') - ->fields(array('weight' => $term->weight)) - ->condition('tid', $term->id(), '=') - ->execute(); + foreach ($changed_terms as $term) { + $term->save(); } // Update the vocabulary hierarchy to flat or single hierarchy. @@ -478,7 +460,7 @@ function theme_taxonomy_overview_terms($variables) { $term = &$form[$key]; $row = array(); - $row[] = (isset($term['#term']['depth']) && $term['#term']['depth'] > 0 ? theme('indentation', array('size' => $term['#term']['depth'])) : ''). drupal_render($term['view']); + $row[] = (isset($term['#term']->depth) && $term['#term']->depth > 0 ? theme('indentation', array('size' => $term['#term']->depth)) : ''). drupal_render($term['view']); if ($form['#parent_fields']) { $term['tid']['#attributes']['class'] = array('term-id'); $term['parent']['#attributes']['class'] = array('term-parent'); @@ -557,9 +539,9 @@ function taxonomy_term_confirm_delete($form, &$form_state, Term $term) { // Always provide entity id in the same form key as in the entity edit form. $form['tid'] = array('#type' => 'value', '#value' => $term->id()); - $form_state['taxonomy']['vocabulary'] = taxonomy_vocabulary_load($term->bundle());; + $form_state['taxonomy']['vocabulary'] = taxonomy_vocabulary_load($term->bundle()); $form['type'] = array('#type' => 'value', '#value' => 'term'); - $form['name'] = array('#type' => 'value', '#value' => $term->name); + $form['name'] = array('#type' => 'value', '#value' => $term->label()); $form['vid'] = array('#type' => 'value', '#value' => $term->bundle()); $form['delete'] = array('#type' => 'value', '#value' => TRUE); return confirm_form($form, diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 47030b9..f8527c4 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -796,19 +796,20 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities } $term->depth = $depth; unset($term->parent); - $term->parents = $parents[$vid][$load_entities ? $term->id() : $term->tid]; + $tid = $load_entities ? $term->id() : $term->tid; + $term->parents = $parents[$vid][$tid]; $tree[] = $term; - if (!empty($children[$vid][$load_entities ? $term->id() : $term->tid])) { + if (!empty($children[$vid][$tid])) { $has_children = TRUE; // We have to continue with this parent later. $process_parents[] = $parent; // Use the current term as parent for the next iteration. - $process_parents[] = $term->id(); + $process_parents[] = $tid; // Reset pointers for child lists because we step in there more often // with multi parents. - reset($children[$vid][$term->id()]); + reset($children[$vid][$tid]); // Move pointer so that we get the correct term the next time. next($children[$vid][$parent]); break; diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index 900ba1a..f3c2971 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -102,11 +102,11 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options = break; case 'name': - $replacements[$original] = $sanitize ? check_plain($term->name) : $term->name; + $replacements[$original] = $sanitize ? check_plain($term->name->value) : $term->name->value; break; case 'description': - $replacements[$original] = $sanitize ? check_markup($term->description, $term->format, '', TRUE) : $term->description; + $replacements[$original] = $sanitize ? check_markup($term->description->value, $term->format->value, '', TRUE) : $term->description->value; break; case 'url': @@ -130,7 +130,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options = case 'parent': if ($parents = taxonomy_term_load_parents($term->id())) { $parent = array_pop($parents); - $replacements[$original] = check_plain($parent->name); + $replacements[$original] = check_plain($parent->name->value); } break; } diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 1e62754..679deb5 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -422,6 +422,6 @@ function views_taxonomy_set_breadcrumb(&$breadcrumb, &$argument) { $args[$argument->position] = $parent->id(); $path = $argument->view->getUrl($args); } - $breadcrumb[$path] = check_plain($parent->name); + $breadcrumb[$path] = check_plain($parent->label()); } }