Skip to content
Snippets Groups Projects
Commit 1651cf34 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #841798 by klausi: error deleting an invalid term.

parent 153ef8bd
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -570,8 +570,7 @@ function taxonomy_term_delete($tid) {
}
}
$term = taxonomy_term_load($tid);
if ($term = taxonomy_term_load($tid)) {
db_delete('taxonomy_term_data')
->condition('tid', $tid)
->execute();
......@@ -583,6 +582,7 @@ function taxonomy_term_delete($tid) {
module_invoke_all('taxonomy_term_delete', $term);
taxonomy_terms_static_reset();
}
}
$tids = $orphans;
}
......
......@@ -337,6 +337,18 @@ class TaxonomyTermUnitTest extends TaxonomyWebTestCase {
'group' => 'Taxonomy',
);
}
function testTermDelete() {
$vocabulary = $this->createVocabulary();
$valid_term = $this->createTerm($vocabulary);
// Delete a valid term.
taxonomy_term_delete($valid_term->tid);
$terms = taxonomy_term_load_multiple(array(), array('vid' => $vocabulary->vid));
$this->assertTrue(empty($terms), 'Vocabulary is empty after deletion');
// Delete an invalid term. Should not throw any notices.
taxonomy_term_delete(42);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment