diff --git a/modules/simpletest/tests/taxonomy_test.module b/modules/simpletest/tests/taxonomy_test.module index 7f5b6f4df50..2bbcf24531e 100644 --- a/modules/simpletest/tests/taxonomy_test.module +++ b/modules/simpletest/tests/taxonomy_test.module @@ -14,19 +14,27 @@ function taxonomy_test_taxonomy_term_load($term) { } /** - * Implementation of hook_taxonomy_term_save(). + * Implementation of hook_taxonomy_term_insert(). */ -function taxonomy_test_taxonomy_term_save($term) { +function taxonomy_test_taxonomy_term_insert($term) { + if (!empty($term->antonyms)) { + foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) { + if ($antonym) { + db_insert('term_antonym')->fields(array('tid' => $term->tid, 'name' => rtrim($antonym)))->execute(); + } + } + } +} + +/** + * Implementation of hook_taxonomy_term_update(). + */ +function taxonomy_test_taxonomy_term_update($term) { taxonomy_test_taxonomy_term_delete($term); if (!empty($term->antonyms)) { foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) { if ($antonym) { - db_insert('term_antonym') - ->fields(array( - 'tid' => $term->tid, - 'name' => rtrim($antonym), - )) - ->execute(); + db_insert('term_antonym')->fields(array('tid' => $term->tid, 'name' => rtrim($antonym)))->execute(); } } } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 86feae168c5..44c4c575fef 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -327,7 +327,7 @@ function taxonomy_save_term(&$form_values) { if (!empty($form_values['tid']) && $form_values['name']) { $status = drupal_write_record('term_data', $form_values, 'tid'); - module_invoke_all('taxonomy_term_save', $term); + module_invoke_all('taxonomy_term_insert', $term); } elseif (!empty($form_values['tid'])) { return taxonomy_del_term($form_values['tid']); @@ -335,7 +335,7 @@ function taxonomy_save_term(&$form_values) { else { $status = drupal_write_record('term_data', $form_values); $term->tid = $form_values['tid']; - module_invoke_all('taxonomy_term_save', $term); + module_invoke_all('taxonomy_term_update', $term); } db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $form_values['tid'], $form_values['tid']);