port to d6. this issue http://drupal.org/node/217676

Suppose you have a multiple hierarchy vocabulary with the following terms:
Politics (tid=1)
-- Event (tid=2)
Sports (tid=3)
-- Tennis (tid=4)
---- Event (tid=2)

Calling taxonomy_get_parents_all(2), you would expect an array with all ancestors of the Event term.
Instead, the array contains (in this order) only the terms Event, Politics and Tennis, while Sports is missing.

If you add a positive weight to Politics, you receive the following vocabulary:

Sports (tid=3)
-- Tennis (tid=4)
---- Event (tid=2)
Politics (tid=1)
-- Event (tid=2)

Calling taxonomy_get_parents_all(2) now gives you the expected array with all ancestors of the Event term: Event, Tennis, Politics and Sports.

So the search for ancestors starts with the branch that has the least weight and then bounces between the branches, searching for another generation of ancestors. But as soon as any ancestor has no more parents, the complete search is stopped.
Instead it would be correct to keep on analyzing the other ancestors if they have more parents.
In the first example: Politics has no more parents, so the algorithm still spits out Tennis, but stops then. Correct would be to abandon the Politics branch, but keep on crawling the Tennis branch. Then we would have found Sports as well.

I also think it would make a lot of sense to add parents to the output array. Maybe we also want some control over how many parent generations are displayed. But these are nice features for D7, not the D6 bug itself.

CommentFileSizeAuthor
multiple_parents.patch741 bytesigor.ro

Comments

Status: Needs review » Needs work

The last submitted patch, multiple_parents.patch, failed testing.

pancho’s picture

Status: Needs work » Closed (duplicate)

Closed as exact duplicate of #217676: taxonomy_term_load_parents_all() doesn't work correctly with multiple hierarchy terms.
Thanks for your patch, which we will take into consideration over there.
However, please don't file separate issues for backports, which generally won't be committed before a bug is fixed in the current dev branch.