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

webchick - September 27, 2008 - 22:00
Title:Standardise taxonomy load/save/delete functions on objects» DX: Standardise taxonomy load/save/delete functions on objects

Subscriiiiiibe.

Also labeling DX.

#2

catch - November 2, 2008 - 23:54
Status:active» needs review

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.

AttachmentSizeStatusTest resultOperations
term_objects.patch14.05 KBIdleUnable to apply patch term_objects.patchView details | Re-test

#3

catch - November 5, 2008 - 00:59

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

AttachmentSizeStatusTest resultOperations
term_objects.patch15.05 KBIdleUnable to apply patch term_objects_0.patchView details | Re-test

#4

Dries - November 5, 2008 - 14:08
Status:needs review» needs work

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

#5

catch - November 6, 2008 - 21:48
Status:needs work» needs review

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.

AttachmentSizeStatusTest resultOperations
whoops.patch2.86 KBIdleUnable to apply patch whoops.patchView details | Re-test

#6

Dries - November 7, 2008 - 18:28

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

#7

catch - November 7, 2008 - 21:15

Here it is with a test :)

AttachmentSizeStatusTest resultOperations
whoops_with_a_test.patch4.1 KBIdleUnable to apply patch whoops_with_a_test.patchView details | Re-test

#8

catch - November 9, 2008 - 00:32

added code comments and whitespace changes.

AttachmentSizeStatusTest resultOperations
whoops_with_a_test.patch4.23 KBIdleUnable to apply patch whoops_with_a_test_0.patchView details | Re-test

#9

catch - November 9, 2008 - 00:36

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

AttachmentSizeStatusTest resultOperations
whoops_with_a_test.patch4.23 KBIdleUnable to apply patch whoops_with_a_test_1.patchView details | Re-test

#10

webchick - November 9, 2008 - 00:57
Status:needs review» fixed

Committed, thanks!

#11

catch - November 9, 2008 - 17:50
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].

#12

catch - November 9, 2008 - 18:30
Status:needs work» fixed

Added documentation http://drupal.org/node/224333#term_functions

--project followup subject--

System Message - November 23, 2008 - 18:33

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

--project followup subject--

System Message - November 23, 2008 - 18:44

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

#13

System Message - November 23, 2008 - 18:51
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.