I create a separate issue based on reported feedback from JordanMagnuson here: https://www.drupal.org/node/2628854#comment-10796874
Here's the feedback itself:
I had a bunch of duplicate terms with the same exact names, that were present at aliases like term/my-term, term/my-term-0, term/my-term-1, etc. When I tried merging these terms (present in a very large vocabulary) using the "autocomplete" to find the term to merge into, I had a couple of issues:
1) When I seached for "my-term", only one of the "my-term" terms came up in the auto-complete.
2) when I tried to go ahead and merge, I got an error message saying that you can't merge into a term that has been selected, or is in the same trunk term... even though I checked the TID to make sure I had NOT selected this "my-term" term when selecting the terms to merge.
3) When I went to the "select from dropdown" option, I was able to complete the merge successfully... but still had the issue that only one of the "my-term" terms showed up in the dropdown. I wanted to merge all these terms into the original "my-term" term (the one with the lowest tid, the one that existed at term/my-term, rather than term/my-term-0, etc.) but the one that showed up was, randomly, something like term/my-term-8.
I'm guessing these issues come from the fact that I had these terms with identical names? (I'm not even sure how this happened, as I'm using a free-tagging taxonomy, which shouldn't allow duplicate terms like this, and haven't seen it happen before... some kind of glitch somewhere, evidently).
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | 2660790-autocomplete_term_trunk-31.patch | 6.5 KB | bucefal91 |
| #31 | interdiff.txt | 4.75 KB | bucefal91 |
| #24 | interdiff.txt | 563 bytes | rade |
| #24 | autocomplete_term_trunk-2660790-24.patch | 5.41 KB | rade |
| #19 | interdiff.txt | 956 bytes | rade |
Comments
Comment #2
bucefal91 commentedThe first 2 items are related to how autocomplete works right now. Basically when you work with an autocomplete widget all it has on hands is the term name and not its TID. So if a vocabulary have terms with identical names, then any term will be considered among those with the same name (the first one it comes across). So autocomplete behavior is unreliable for the case of terms with the same name.
Probably I should improve it, however, so it can handle this case of identical names. After all, this module is an useful tool for website admins to bring their vocabularies in order and we shouldn't fail the mission just because a vocabulary has terms with the same name.
As for the 3rd position: what you described is not expected. I checked the code and right now on my dummy Drupal installation tried it with the same outcome - you should have seen all terms. The only condition why the branch terms could have been incomplete is if they were children of the selected trunk term. For a matter of simple logic one cannot merge a term into its child because it would create inconsistency in the hierarchy. Could you double check this issue with select widget? If you still see problem, would you tell me your vocabulary terms and the hierarchy relationship between them? So I can debug it better.
Comment #3
rade commentedWe ran into the same issue where we needed to merge multiple terms with the exact same name and they didn't show up in the autocomplete.
Here is a patch to fix that.
Comment #4
rade commentedAh, the patch had a small typo. Here is a fixed one.
Comment #13
rade commentedAdding also patch against release 7.x-1.3.
Comment #14
rade commentedNew patch against dev, let's see if test pass this time.
Comment #19
rade commentedUpdated tests again.
Comment #24
rade commentedOoonce again
Comment #29
rade commentedThe latest patch fails due to "Fatal error: Call to undefined function synonyms_behavior_settings_save() in /var/www/html/sites/all/modules/term_merge/term_merge.test on line 1282", which is unrelated to my changes. The cause of the error is that the Synonyms module has been updated and the synonyms_behavior_settings_save() function has been removed.
Changing back to "Needs review".
Comment #30
bucefal91 commentedHello, Rade!
Alright, let's get it done :) Seems like you were able to serve your own need, so there is no direct urgency. I would first settle down the integration with Synonyms and then review your patch (this way we can leverage existing SimpleTests when testing your patch). I am the maintainer of Synonyms module, so it will be quick.
I got the issue for Synonyms integration here #2728743: Synonyms 7.x-1.5 integration. In a matter of few hours it will have a patch.
Comment #31
bucefal91 commentedI've committed the synonyms integration, so we can resolve this one now. Your patch looks really good, I wish all the patches were like this one :) I only have a handful of questions/proposals:
\((\d+\)$(with the$at the end to make sure we do not catch things like "My first (1) term", for example).$term->name ($term->tid).All of the items above are included in the patch I enclose to this comment. What would you say?
Comment #33
bucefal91 commentedI've committed my patch (#31) since there was no feedback in the last few days.