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.

Comments

webchick’s picture

Title: Standardise taxonomy load/save/delete functions on objects » DX: Standardise taxonomy load/save/delete functions on objects

Subscriiiiiibe.

Also labeling DX.

catch’s picture

Status: Active » Needs review
StatusFileSize
new14.05 KB

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.

catch’s picture

StatusFileSize
new15.05 KB

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...

dries’s picture

Status: Needs review » Needs work

Also committed this patch. Please update the docs! :)

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB

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.

dries’s picture

Let's add a test! We should set the right example. Thanks catch. :)

catch’s picture

StatusFileSize
new4.1 KB

Here it is with a test :)

catch’s picture

StatusFileSize
new4.23 KB

added code comments and whitespace changes.

catch’s picture

StatusFileSize
new4.23 KB

and fixed a typo that appears to have become unfixed in one of the revisions.

webchick’s picture

Status: Needs review » Fixed

Committed, thanks!

catch’s picture

Status: Fixed » Needs work

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].

catch’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

salvis’s picture

The committed patch in #3 has an undesired side effect. I've opened a new issue: #850690: Regression: Set the tid of the newly created forum or container