This is my tree:

Belgique
-- Politique
-- Economie
International
-- Politique (same term id, just has other parent)
-- Economie (same term id, just has other parent)

The vocabulary has multiple select options and multiple hierarchy.
Options in hierarchical select settings:
- Save term lineage
- Level choice: force use to select term from deepest level

Do this:
1) Choose belgique - politique and push add so this choice is dropped in the selection box.
2) Choose International - economie and push add
When triggering 2 I would like to see only the international > economie added to the selection box, instead
a) everything from the parent Belgique & International is added.
b) the remove clicks stop working so I can't remove any selected options anymore.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Priority: Normal » Critical

Reproduced. I'll work on a fix later today.

Thanks for the detailed yet concise bug report!

Wim Leers’s picture

Status: Active » Postponed (maintainer needs more info)

While I was thinking about this, I found the cause already.

When you add something to the dropbox, only the ID (in the case of taxonomy: the term id) is sent to the server, as well as all ID's of the already selected items. Using this set of ID's, it reconstructs every valid hierarchy of ID's. And that's where the problem lies: taxonomy's ID's are no longer bound to unique hierarchies when "multiple parents" is enabled.

This implies that a similar problem will occur if you'd have been able to set it correctly and then go to edit the node.

While verifying this implication, it seemed that Drupal itself was unable to select the originally selected terms, for the same reasons. If you select: Belgique, Belgique -> economie, International, International -> politique, then *all* terms will end up being selected!
Could you please try to reproduce this? And if you can reproduce this, I'd like to know if you agree with me that this is the *exact* same (aka buggy, at least from your pov/use case) behavior as in the HS module?

swentel’s picture

I turned the HS off and indeed, Drupal doesn't know what original ones were selected. Damn, this is well a real bummer for me.
My use case is a bit borked right now, because say I'm in a view 'Belgique - politique' , I need to show the articles from Belgium first and then other articles which are also tagged politique but then in the International section. I could of course turn of Multiple Hierarchy in the category and duplicate 'politique' but I somehow need to create a relationship between those two.

swentel’s picture

Of course, When HS is on and you edit a node and the four are selected, I'm unable to remove any of them, so the removal of items does remain a bug *I think*.

Wim Leers’s picture

Priority: Critical » Normal

True! But the cause for that is actually the same: the terms that you remove from the selection, are included in the remaining 3 terms. So what it reconstructs the hierarchy, it will also find the combination that we've just removed…
Nevertheless, I'll have to fix this.

Wim Leers’s picture

Title: Multiple select & Multiple parents sometimes triggers faulty selections » Multiple select: impossible to remove selections of which the child term has multiple parents
FileSize
9.1 KB
10.15 KB
10.68 KB
10.14 KB
11.44 KB

I've fixed this behavior now. It still feels odd though.

1) Select "belgique > economie", then select "international > politique". All 4 combinations will now be selected, due to the fact that "economie" and "politique" both have multiple parents (both have belgique and international as parents).
This is depicted in selection.png

2) Now remove the first entry in the dropbox: belgique > economie. This will remove the deepest term, in this case "economie", from ALL entries. Why is this valid behavior? When multiple parents are disabled, the deepest term is always unique. When it's enabled, this mechanism allows you to (gradually) delete items.
This is depected in first_dropbox_entry_removed.png.

Now, to explain the behavior better, I extended your vocabulary: "politique" has a "test" child now. But since "politique" has multiple parents, it exists at both "belgique > politique > test" and "international > politique > test".
See the remaining 3 images to find out how that works.

Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Fixed

Fixed!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.