From de0945e9294eecdfc00c54fab61d6d54e12f15eb Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 20 Jun 2009 18:32:04 +0000 Subject: - Patch #490432 by mfb, catch, bangpound: taxonomy_form_vocabulary always returned error. --- modules/taxonomy/taxonomy.admin.inc | 2 +- modules/taxonomy/taxonomy.test | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc index 177db165e..d92214086 100644 --- a/modules/taxonomy/taxonomy.admin.inc +++ b/modules/taxonomy/taxonomy.admin.inc @@ -222,7 +222,7 @@ function taxonomy_form_vocabulary_validate($form, &$form_state) { // Do not allow duplicate machine names. $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vocabulary) { - if ($machine_name == $vocabulary->machine_name && (!(isset($form_state['values']['vid']) && $vocabulary->vid != $form_state['values']['vid']))) { + if ($machine_name == $vocabulary->machine_name && (!isset($form_state['values']['vid']) || $vocabulary->vid != $form_state['values']['vid'])) { form_set_error('machine_name', t('This machine-readable name is already in use by another vocabulary and must be unique.')); } } diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 6264ba824..897dc5220 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -69,9 +69,10 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase { // Create a new vocabulary. $this->clickLink(t('Add vocabulary')); $edit = array(); + $machine_name = drupal_strtolower($this->randomName()); $edit['name'] = $this->randomName(); $edit['description'] = $this->randomName(); - $edit['machine_name'] = drupal_strtolower($this->randomName()); + $edit['machine_name'] = $machine_name; $edit['help'] = $this->randomName(); $edit['nodes[article]'] = 'article'; $edit['tags'] = 1; @@ -86,12 +87,12 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase { $this->clickLink(t('edit vocabulary')); $edit = array(); $edit['name'] = $this->randomName(); - $edit['machine_name'] = drupal_strtolower($this->randomName()); $this->drupalPost(NULL, $edit, t('Save')); $this->drupalGet('admin/content/taxonomy'); $this->assertText($edit['name'], t('Vocabulary found in the vocabulary overview listing.')); // Try to submit a vocabulary with a duplicate machine name. + $edit['machine_name'] = $machine_name; $this->drupalPost('admin/content/taxonomy/add', $edit, t('Save')); $this->assertText(t('This machine-readable name is already in use by another vocabulary and must be unique.'), t('Duplicate machine name validation was successful')); -- cgit v1.2.3