Skip to content
Snippets Groups Projects
Commit 1eb27ae0 authored by catch's avatar catch
Browse files

Issue #2077387 by wadmiraal, guschilds: Fixed Taxonomy term is improperly...

Issue #2077387 by wadmiraal, guschilds: Fixed Taxonomy term is improperly deleted when only one of two parents is deleted.
parent 034d5235
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
......@@ -157,9 +157,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
foreach ($children as $child) {
// If the term has multiple parents, we don't delete it.
$parents = taxonomy_term_load_parents($child->id());
// Because the parent has already been deleted, the parent count might
// be 0.
if (count($parents) <= 1) {
if (empty($parents)) {
$orphans[] = $child->id();
}
}
......
......@@ -32,6 +32,27 @@ function testTermDelete() {
entity_delete_multiple('taxonomy_term', array(42));
}
/**
* Deleting a parent of a term with multiple parents does not delete the term.
*/
function testMultipleParentDelete() {
$vocabulary = $this->createVocabulary();
$parent_term1 = $this->createTerm($vocabulary);
$parent_term2 = $this->createTerm($vocabulary);
$child_term = $this->createTerm($vocabulary);
$child_term->parent = array($parent_term1->id(), $parent_term2->id());
$child_term->save();
$child_term_id = $child_term->id();
$parent_term1->delete();
$child_term = entity_load('taxonomy_term', $child_term_id, TRUE);
$this->assertTrue(!empty($child_term), 'Child term is not deleted if only one of its parents is removed.');
$parent_term2->delete();
$child_term = entity_load('taxonomy_term', $child_term_id, TRUE);
$this->assertTrue(empty($child_term), 'Child term is deleted if all of its parents are removed.');
}
/**
* Test a taxonomy with terms that have multiple parents of different depths.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment