When saving term lineage turn on, it seems that the selection fails to load correctly.
This is appearing on first load of a node edit form. I can see that the terms are being saved.
I have a 2 level taxonomy.

I've stepped through the code and can see that where the hierarchy is generated, it seems to select the wrong term as the selected term for the parent level.
Probably somewhere here where it's doing the funky taxonomy tid ordering.

  $hierarchy = _hierarchical_select_hierarchy_generate($config, $hs_selection, $element['#required'], $dropbox);

i.e. 1450 is the tid, yet doesn't appear in the levels array, because 1450 is the selected term from the children level.

$hierarchy = Object of: stdClass
 levels = Array [1]
  0 = Array [72]
   ...
 lineage = Array [1]
  0 = (int) 1450

Hope this makes sense.

Michael

CommentFileSizeAuthor
#10 258708.patch1.19 KBwim leers
#5 Settings.gif26.92 KBpingers

Comments

wim leers’s picture

Assigned: Unassigned » wim leers
Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Is this a node that was created when save_lineage was still disabled? Because then this is normal behavior: no valid lineage can be reconstructed, because not enough items are selected.

E.g. suppose you selected "7 series" before save_lineage was enabled. If you then turn on save_lineage and edit the node, no terms will be listed, because the parent term ("bmw") was not selected, and because of that, no lineage could be reconstructed.

wim leers’s picture

Is this a node that was created when save_lineage was still disabled? Because then this is normal behavior: no valid lineage can be reconstructed, because not enough items are selected.

E.g. suppose you selected "7 series" before save_lineage was enabled. If you then turn on save_lineage and edit the node, no terms will be listed, because the parent term ("bmw") was not selected, and because of that, no lineage could be reconstructed.

pingers’s picture

I think you're right. I'll try it when I get a chance tonight - on a fresh node.

Cheers,
Michael

wim leers’s picture

Status: Postponed (maintainer needs more info) » Fixed

Just for the record: it's of course possible to support these transitions. But it can give unexpected results. So it's better to make the right choice from the beginning, so take your time while deciding on that!

pingers’s picture

Status: Fixed » Active
StatusFileSize
new26.92 KB

Still experiencing the same behaviour after creating a few new nodes.

Please see settings attached.

Okay, when I debugged this time, before executing the line of code in my first post, I switched the values of the following array:
Original

$hs_selection = Array [2]
 0 = (int) 1448
 1 = (int) 1220

Switched

$hs_selection = Array [2]
 0 = (int) 1220
 1 = (int) 1448

Then it loaded the hs element perfectly.

Hopefully this is enough info to get you on the right track :)

EDIT: Attach the image.... sigh. Must be Friday.

wim leers’s picture

Hm, that should not happen. Seems like a bug indeed then.

I've got very little time, so it'd help if you could provide me with FTP/SSH access to this web site, so I don't have to set up a testing environment.

pingers’s picture

I'll see what I can do - under an NDA for the site - but it's going public very soon - as in few days.
I'll do my best to provide access to what you need.

Regards,
Michael

wim leers’s picture

Well, if you want me to sign an NDA to access it, no problem for me (had to do that before). But I'm not sure if that's your call.

wim leers’s picture

Category: support » bug
Priority: Normal » Critical

Reproduced. Happens when:
- save_lineage = 1
- dropbox is disabled

Guess at the cause: multiple values is not being enabled automatically for the vocabulary.

wim leers’s picture

Title: Editing a node, no terms selected » Term lineage not loaded properly
Status: Active » Fixed
StatusFileSize
new1.19 KB

Found it. The cause was that I was validating the hierarchy *before* it was reconstructed. That's why this did *not* happen when tid1 < tid2 < tid3, which is often the case.

pingers’s picture

Lovely work!

wim leers’s picture

So it works? :)

esllou’s picture

it essentially works but as I reported here:#259903: When using "Save Term Lineage", term data not saved on node/edit, it seems to be having an odd side effect. As always, happy to help in further testing if tweaks are needed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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