Status:
A partial fix has been committed to D7 in #346156-14: term delete fails because of misnamed function.
However, per #13 and a duplicate issue against D7 (see #19) this still doesn't work correctly.
A new patch against D7 is available in #16
Related Issues:
#1347542: [META] Taxonomy API improvements
#251595: Add taxonomy_term_load_descendents()
#346156: term delete fails because of misnamed function
#394422: Taxonomy terms should be listed in order they are entered
#1207326: Refactor taxonomy hierarchy API for performance, consistency, and convenience
Original report by Pancho
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.