diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index f5f6416..02730c0 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -588,7 +588,7 @@ function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) { function forum_form_taxonomy_vocabulary_form_alter(&$form, &$form_state, $form_id) { $vid = config('forum.settings')->get('vocabulary'); $vocabulary = $form_state['controller']->getEntity($form_state); - if (!$vocabulary->isNew() && $vid == $vocabulary->id()) { + if ($vid == $vocabulary->id()) { $form['help_forum_vocab'] = array( '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'), '#weight' => -1, diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php index b66da01..1395014 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php @@ -134,15 +134,6 @@ function testTaxonomyVocabularyLoadMultiple() { $this->assertEqual(array_shift($vocabularies)->id(), $vocabulary3->id(), 'Vocabulary loaded successfully by ID.'); $this->assertEqual(array_shift($vocabularies)->id(), $vocabulary2->id(), 'Vocabulary loaded successfully by ID.'); $this->assertEqual(array_shift($vocabularies)->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by ID.'); - - // Fetch vocabulary 1 by name. - // @todo Commented for EntityStorageControllerInterface::loadByProperties() - //$vocabulary = current(entity_load_multiple_by_properties('taxonomy_vocabulary', array('name' => $vocabulary1->name))); - //$this->assertEqual($vocabulary->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by name.'); - - // Fetch vocabulary 1 by name and ID. - // @todo Commented for EntityStorageControllerInterface::loadByProperties() - //$this->assertEqual(current(taxonomy_vocabulary_load_multiple(array($vocabulary1->id()), array('name' => $vocabulary1->name)))->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by name and ID.'); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index 44b60fd..96f2637 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -39,7 +39,6 @@ public function form(array $form, array &$form_state, EntityInterface $vocabular 'exists' => 'taxonomy_vocabulary_load', 'source' => array('name'), ), - '#disabled' => !$vocabulary->isNew(), ); $form['description'] = array( '#type' => 'textfield', diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index b96fdd4..87fe0d8 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -677,14 +677,14 @@ function taxonomy_term_load_parents_all($tid) { * * @param $tid * A taxonomy term ID. - * @param $bundle + * @param $vid * An optional vocabulary ID to restrict the child search. * * @return * An array of term objects that are the children of the term $tid, or an * empty array when no children exist. */ -function taxonomy_term_load_children($tid, $bundle = NULL) { +function taxonomy_term_load_children($tid, $vid = NULL) { $children = &drupal_static(__FUNCTION__, array()); if ($tid && !isset($children[$tid])) { @@ -692,8 +692,8 @@ function taxonomy_term_load_children($tid, $bundle = NULL) { $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid'); $query->addField('t', 'tid'); $query->condition('h.parent', $tid); - if ($bundle) { - $query->condition('t.vid', $bundle); + if ($vid) { + $query->condition('t.vid', $vid); } $query->addTag('term_access'); $query->orderBy('t.weight'); @@ -708,8 +708,8 @@ function taxonomy_term_load_children($tid, $bundle = NULL) { /** * Create a hierarchical representation of a vocabulary. * - * @param $bundle - * Which vocabulary to generate the tree for. + * @param $vid + * The vocabulary ID to generate the tree for. * @param $parent * The term ID under which to generate the tree. If 0, generate the tree * for the entire vocabulary. @@ -727,17 +727,17 @@ function taxonomy_term_load_children($tid, $bundle = NULL) { * Results are statically cached. Term objects will be partial or complete * depending on the $load_entities parameter. */ -function taxonomy_get_tree($bundle, $parent = 0, $max_depth = NULL, $load_entities = FALSE) { +function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE) { $children = &drupal_static(__FUNCTION__, array()); $parents = &drupal_static(__FUNCTION__ . ':parents', array()); $terms = &drupal_static(__FUNCTION__ . ':terms', array()); // We cache trees, so it's not CPU-intensive to call taxonomy_get_tree() on a // term and its children, too. - if (!isset($children[$bundle])) { - $children[$bundle] = array(); - $parents[$bundle] = array(); - $terms[$bundle] = array(); + if (!isset($children[$vid])) { + $children[$vid] = array(); + $parents[$vid] = array(); + $terms[$vid] = array(); $query = db_select('taxonomy_term_data', 't'); $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid'); @@ -746,25 +746,25 @@ function taxonomy_get_tree($bundle, $parent = 0, $max_depth = NULL, $load_entiti ->addTag('term_access') ->fields('t') ->fields('h', array('parent')) - ->condition('t.vid', $bundle) + ->condition('t.vid', $vid) ->orderBy('t.weight') ->orderBy('t.name') ->execute(); foreach ($result as $term) { - $children[$bundle][$term->parent][] = $term->tid; - $parents[$bundle][$term->tid][] = $term->parent; - $terms[$bundle][$term->tid] = $term; + $children[$vid][$term->parent][] = $term->tid; + $parents[$vid][$term->tid][] = $term->parent; + $terms[$vid][$term->tid] = $term; } } // Load full entities, if necessary. The entity controller statically // caches the results. if ($load_entities) { - $term_entities = taxonomy_term_load_multiple(array_keys($terms[$bundle])); + $term_entities = taxonomy_term_load_multiple(array_keys($terms[$vid])); } - $max_depth = (!isset($max_depth)) ? count($children[$bundle]) : $max_depth; + $max_depth = (!isset($max_depth)) ? count($children[$vid]) : $max_depth; $tree = array(); // Keeps track of the parents we have to process, the last entry is used @@ -778,24 +778,24 @@ function taxonomy_get_tree($bundle, $parent = 0, $max_depth = NULL, $load_entiti $parent = array_pop($process_parents); // The number of parents determines the current depth. $depth = count($process_parents); - if ($max_depth > $depth && !empty($children[$bundle][$parent])) { + if ($max_depth > $depth && !empty($children[$vid][$parent])) { $has_children = FALSE; - $child = current($children[$bundle][$parent]); + $child = current($children[$vid][$parent]); do { if (empty($child)) { break; } - $term = $load_entities ? $term_entities[$child] : $terms[$bundle][$child]; - if (isset($parents[$bundle][$term->tid])) { + $term = $load_entities ? $term_entities[$child] : $terms[$vid][$child]; + if (isset($parents[$vid][$term->tid])) { // Clone the term so that the depth attribute remains correct // in the event of multiple parents. $term = clone $term; } $term->depth = $depth; unset($term->parent); - $term->parents = $parents[$bundle][$term->tid]; + $term->parents = $parents[$vid][$term->tid]; $tree[] = $term; - if (!empty($children[$bundle][$term->tid])) { + if (!empty($children[$vid][$term->tid])) { $has_children = TRUE; // We have to continue with this parent later. @@ -805,17 +805,17 @@ function taxonomy_get_tree($bundle, $parent = 0, $max_depth = NULL, $load_entiti // Reset pointers for child lists because we step in there more often // with multi parents. - reset($children[$bundle][$term->tid]); + reset($children[$vid][$term->tid]); // Move pointer so that we get the correct term the next time. - next($children[$bundle][$parent]); + next($children[$vid][$parent]); break; } - } while ($child = next($children[$bundle][$parent])); + } while ($child = next($children[$vid][$parent])); if (!$has_children) { // We processed all terms in this hierarchy-level, reset pointer // so that this function works the next time it gets called. - reset($children[$bundle][$parent]); + reset($children[$vid][$parent]); } } } @@ -947,11 +947,11 @@ function _taxonomy_get_tid_from_term(Term $term) { * * @see drupal_explode_tags() */ -function taxonomy_implode_tags($tags, $bundle = NULL) { +function taxonomy_implode_tags($tags, $vid = NULL) { $typed_tags = array(); foreach ($tags as $tag) { // Extract terms belonging to the vocabulary in question. - if (!isset($bundle) || $tag->bundle() == $bundle) { + if (!isset($vid) || $tag->bundle() == $vid) { // Make sure we have a completed loaded taxonomy term. if ($tag instanceof EntityInterface && $label = $tag->label()) { // Commas and quotes in tag names are special cases, so encode 'em.