I am integrating unitag with community tags and am calling unitag_taxonomy_terms_resolve_tags() in order to do so. If the vocabulary is configured as read-only the 'parsed' terms are returned indexed by their tids which is what I would expect. However, if the vocabulary is not configured to be read-only then the following code means that the parsed terms are merged with new terms and tid indexes are lost:
if (!in_array($vid, $unitag_config['readonly'])) {
// Add new terms - use array_merge to ensure that numeric indices are
// not overwritten.
$tags_parsed = array_merge($tags_parsed, $terms_new);
$terms_new = array();
}
Is this intended or a bug? The comment in the code suggests it is not intended but then I can't see why new terms are merged with parsed terms instead of being returned in the 'new' array. As it stands, I have to iterate through the parsed terms and repeat the existing term test.
I should point out that it works fine with the node edit form. It's just that as an API call (which you may not have intended) it doesn't do what I would expect it to.
Andy
Comments
Comment #1
Zen CreditAttribution: Zen commentedI'm not sure what you mean by "and tid indexes are lost". The tids of the parsed tags should be retained as they're the first argument in the array_merge call. I dare say that you might face a problem because I've shoved new terms into the $tags_parsed array along with manufactured tids which I reckon could upset things. Please clarify.
My apologies for the lateness of my reply.
-K
Comment #2
chaps2 CreditAttribution: chaps2 commentedThe tid indexes (keys) are lost because array_merge re-numbers numeric keys.
Good to see activity on Unitag again!