$vid = install_taxonomy_get_vid('Forums');
install_taxonomy_add_term($vid, 'Types of Birds', 'Discussions grouped by bird classifications.');
$container = install_taxonomy_get_tid('Types of Birds');
variable_set('forum_containers', array($container));
// Now add the forums.
install_taxonomy_add_term($vid, 'Raptors', 'Birds of prey.', array('parent' => $container));
install_taxonomy_add_term($vid, 'Water birds', 'Birds that live on or near the water.', array('parent' => $container));
For whatever reason, $vid gets set to 0 somewhere in taxonomy_term_save(), and things don't show up under the container like they should. I spent some time in a debugger on this and am mystified. I suspect this line from install_taxonomy_add_term():
$term = array_unique(array_merge($defaults, $properties));
But wasn't able to spot where it's getting screwed up.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | install_profile_api_subterms.patch | 598 bytes | quicksketch |
Comments
Comment #1
quicksketchI thinks this officially qualifies as a "dumb" bug. :P
You're totally right, the problem was in that line. The call to array_unique() is completely unnecessary. Here's what was happening:
Before the array_unique() call:
After the array_unique() call:
array_unique compares the values of the arrays and removes any duplicates. Since the "vid" and "parent" values were both equal to "1", the vid value was being dropped. The same problem would occur if vid were set the same as weight (or other keys). Simply removing the array_unique() fixes the problem. I can't think of any reason for it's existence, since the keys are already unique.
Comment #2
quicksketchI've committed the above patch.
Comment #3
quicksketchI found this same problem exists for install_add_vocabulary(). However, since most of the database columns set reasonable defaults for vocabularies, this problem was less noticeable. I've remove dthe array_unique() from this function also.
I've backported these changes to the 5--2 branch.