diff options
-rw-r--r-- | modules/taxonomy/taxonomy.module | 4 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.test | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index b68a63949..28f85d994 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -334,7 +334,9 @@ function taxonomy_term_save($term) { $status = drupal_write_record('term_data', $term); module_invoke_all('taxonomy_term_update', $term); } - db_delete('term_relation')->condition('tid1', $term->tid, 'OR')->condition('tid2', $term->tid)->execute(); + + $or = db_or()->condition('tid1', $term->tid)->condition('tid2', $term->tid); + db_delete('term_relation')->condition($or)->execute(); if (!empty($term->relations)) { foreach ($term->relations as $related_id) { diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 4aa5cc9e7..bc85bbe68 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -268,9 +268,16 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $edit = array(); $edit['relations[]'] = $term2->tid; $this->drupalPost('taxonomy/term/' . $term1->tid . '/edit', $edit, t('Save')); - $related = taxonomy_get_related($term1->tid); $this->assertTrue(isset($related[$term2->tid]), t('Related term was found')); + // Create a third term. + $term3 = $this->createTerm($this->vocabulary->vid); + $edit['relations[]'] = $term3->tid; + $this->drupalPost('taxonomy/term/' . $term1->tid . '/edit', $edit, t('Save')); + + $related = taxonomy_get_related($term1->tid); + $this->assertTrue(isset($related[$term3->tid]), t('Related term was found')); + $this->assertFalse(isset($related[$term2->tid]), t('Term relationship no longer exists')); } /** |