It should be possible to do:
$term = taxonomy_term_load($tid);
taxonomy_term_save($term);
Same as you can with any other entity in core. However our crappy hierarchy handling breaks on this.
For one, unless you explicitly load term->parent it'll get wiped. Additionally we delete then insert on both inserts and updates when it's only needed for inserts.
i'd prefer it we could load $parents in taxonomy_term_load() but that's much more of an API change. The only one here is that if you wanted to kill parents in a programmatic update you'd have to explicitly set parent to 0.
Comments
Comment #1
catchSince this is data loss, and updating terms is a perfectly reasonable thing to want to do, and the patch is straightforward, bumping to critical.
Comment #2
catchSlightly slimmer version
Comment #3
catchComment #4
catchAdded to existing test. This should have one fail.
Comment #5
catchTest + patch combined.
Comment #6
dries commentedThe code would be slightly more intuitive if the delete and the insert were closer to each other in the code. That said, this looks like a valid fix.
Comment #7
catchWe could switch the update/insert if/else, that'd get them a bit closer I guess.
Comment #8
catchUntested patch switching the order, also removed the $term->name check since that seems just odd here.
Comment #9
dries commentedThis looks better to me, and the tests seem to work. Marking this RTBC.
Comment #10
dries commentedReviewed it once more, and decided to commit this patch to CVS HEAD. Thanks!