#936836 by swentel: Fixed critical issue Autocomplete term widget doesn't return any values - unknown key vid.

merge-requests/26/head
Angie Byron 2010-10-13 01:25:11 +00:00
parent 90c1a34782
commit 8c89469d20
2 changed files with 10 additions and 4 deletions

View File

@ -91,8 +91,9 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
// Part of the criteria for the query come from the field's own settings. // Part of the criteria for the query come from the field's own settings.
$vids = array(); $vids = array();
$vocabularies = taxonomy_vocabulary_get_names();
foreach ($field['settings']['allowed_values'] as $tree) { foreach ($field['settings']['allowed_values'] as $tree) {
$vids[] = $tree['vid']; $vids[] = $vocabularies[$tree['vocabulary']]->vid;
} }
$query = db_select('taxonomy_term_data', 't'); $query = db_select('taxonomy_term_data', 't');

View File

@ -466,7 +466,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$this->drupalGet('node/' . $node->nid); $this->drupalGet('node/' . $node->nid);
$this->assertText($term2->name, t('Term is displayed when viewing the node.')); $this->assertText($term2->name, t('Term is displayed when viewing the node.'));
//Preview the node // Preview the node.
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Preview')); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Preview'));
$this->assertNoUniqueText($term2->name, t('Term is displayed when previewing the node.')); $this->assertNoUniqueText($term2->name, t('Term is displayed when previewing the node.'));
$this->drupalPost(NULL, NULL, t('Preview')); $this->drupalPost(NULL, NULL, t('Preview'));
@ -530,6 +530,11 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$this->assertText($term_name, t('The term %name appears on the node page after one term %deleted was deleted', array('%name' => $term_name, '%deleted' => $term1->name))); $this->assertText($term_name, t('The term %name appears on the node page after one term %deleted was deleted', array('%name' => $term_name, '%deleted' => $term1->name)));
} }
$this->assertNoText($term1->name, t('The deleted term %name does not appear on the node page.', array('%name' => $term1->name))); $this->assertNoText($term1->name, t('The deleted term %name does not appear on the node page.', array('%name' => $term1->name)));
// Test autocomplete on term 2.
$input = substr($term2->name, 0, 3);
$this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input);
$this->assertRaw('{"' . $term2->name . '":"' . $term2->name . '"}', t('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term2->name)));
} }
/** /**
@ -586,7 +591,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$term->description = ''; $term->description = '';
taxonomy_term_save($term); taxonomy_term_save($term);
$this->drupalGet('taxonomy/term/' . $term->tid); $this->drupalGet('taxonomy/term/' . $term->tid);
$this->assertNoPattern('|class="term-listing-heading"|', 'Term page did not display the term description when description was blank.'); $this->assertNoPattern('|class="term-listing-heading"|', 'Term page did not display the term description when description was blank.');
// Check that the term feed page is working. // Check that the term feed page is working.
$this->drupalGet('taxonomy/term/' . $term->tid . '/feed'); $this->drupalGet('taxonomy/term/' . $term->tid . '/feed');
@ -1036,7 +1041,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
$tests['[term:node-count]'] = 0; $tests['[term:node-count]'] = 0;
$tests['[term:parent:name]'] = '[term:parent:name]'; $tests['[term:parent:name]'] = '[term:parent:name]';
$tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name); $tests['[term:vocabulary:name]'] = check_plain($this->vocabulary->name);
foreach ($tests as $input => $expected) { foreach ($tests as $input => $expected) {
$output = token_replace($input, array('term' => $term1), array('language' => $language)); $output = token_replace($input, array('term' => $term1), array('language' => $language));
$this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy term token %token replaced.', array('%token' => $input)));