DX: Standardise taxonomy load/save/delete functions on objects
catch - September 27, 2008 - 09:00
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | taxonomy.module |
| Category: | bug report |
| Priority: | critical |
| Assigned: | catch |
| Status: | closed |
Description
taxonomy_save_term(), apart from not having standardised naming (see #295392: DX: taxonomy_del_vocabulary/term -> taxonomy_delete_vocabulary/term) - also takes $form_values as argument, whereas it ought to be an API function taking an object independent of the forms system - as brought up by Crell on #306224: EOL Taxonomy sprint: add proper taxonomy term hooks.
So, we should pass it an object instead. Patch forthcoming in the next couple of days.

#1
Subscriiiiiibe.
Also labeling DX.
#2
Here's a patch.
I'm doing a cast to object in case taxonomy_term_save() is passed an array. I'd like to get rid of this, but this means rewriting 90% of the existing taxonomy term tests (same for vocabulary which needs the same treatment). I can do that here, but ideally it belongs in a different issue. Also drupal_write_record() casts to array internally as well, so I dunno if we might want to leave it as a helper along those lines.
#3
Following pwolanin's improvements to #329140: Make vocabulary load/insert/update/save like terms, here's the same for taxonomy terms. taxonomy_term_save() can no longer be used to delete a term - apparently this wasn't used anywhere in core, but still...
#4
Also committed this patch. Please update the docs! :)
#5
I missed a couple of cast to objects, and one typo made it through. Found this when saving new terms from the node form - so we need a test for that, and taxonomy.test is a real mess in general.
#6
Let's add a test! We should set the right example. Thanks catch. :)
#7
Here it is with a test :)
#8
added code comments and whitespace changes.
#9
and fixed a typo that appears to have become unfixed in one of the revisions.
#10
Committed, thanks!
#11
Back to needs work for docs.
Also byproduct of dbtng conversion was this bug (also not tested, but now it is) #332145: UNSTABLE-3 blocker: taxonomy_form_term_submit passes empty string as parent [dbtng conversion regression].
#12
Added documentation http://drupal.org/node/224333#term_functions
--project followup subject--
Automatically closed -- issue fixed for two weeks with no activity.
--project followup subject--
Automatically closed -- issue fixed for two weeks with no activity.
#13
Automatically closed -- issue fixed for two weeks with no activity.