Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: http://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/fu...
Some of the $vocabulary properties that are listed as mandatory, e.g. the VID cause a new vocabulary save to fail. The documentation should be updated to explain what is required for to save a new vocabulary, e.g.
taxonomy_vocabulary_save((object) array(
'name' => 'Vocabulary Name',
'machine_name' => 'vocab_short_name',
));
Providing a vocabulary update example would be very useful too.
Comments
Comment #1
jhodgdonGood idea on the documentation. We don't provide examples in the docs though -- you can add one as a comment, or try one of the "functions that call this function" for an actual usage example.
This is a 7.x issue only, by the way. It's totally changed in 8.x apparently.
Probably a good Novice project to fix this... there's also a typo in the @return section -- missing a space in "updated(SAVED_UPDATED)".
Comment #2
salah1I got this(assigned to myself).
Also, you want me to put note or something on the api documentation.
http://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/functi...
Needless to say, thank you all you do "jhodgdon"
Comment #3
jhodgdonYes, you need to modify the documentation header for the taxonomy_vocabulary_save() function, to add information about what to do to save a new vocabulary vs. updating an existing vocabulary.
See
http://drupal.org/novice (instructions on how to contribute a patch)
http://drupal.org/node/1354 (standards for documentation headers)
Comment #4
salah1Remove the vid parameter(auto_increment field) which is neither mandatory nor optional for the function call.
When you call the function with the other mandatory parameters, "vid" is auto generated for you.
I also, took care of the space issue mentioned in comment#1
see Patch attached.
Comment #5
jhodgdonThanks! But... I think if you save an existing vocabulary, you need the 'vid' property to be set?
Comment #6
salah1The function name being "taxonomy_vocabulary_save($vocabulary)", it could be very confusing.
Right now it appears as follow which looks like mandatory:
vid: The ID of the vocabulary.
Would you rather leave it there, but add some comments? such as:
vid: The ID of the vocabulary(to be used to update existing vocabulary only).
Comment #7
jhodgdonYes, something like #6 would be good.
Comment #8
salah1Done (see patch).
Comment #9
salah1Comment #10
jhodgdonLooks good! Maybe it needs "an" in there: "(used to update *an* existing vocabulary only)"? And the original report here stated that you *can't* have 'vid' if you are saving a new vocabulary, so maybe this point could be made a little more strongly?
Comment #11
salah1Sure, i added the change requested.
Comment #12
jhodgdonWhat I meant in #10 about "more strongly" making the point was that we should change the text on the 'vid' entry to say something like: "Omit if creating a new vocabulary", because this was not clear to the person who originally filed this issue. The current text says it is only *used* if you are updating an existing vocabulary, but apparently you get an error when creating a new one if the vid is present, so we need to make the point more strongly, I think?
Comment #13
salah1How does this look
Comment #14
jhodgdonBetter! This is definitely much more clear. There are a couple of typographical/grammatical type issues with this though:
- Omit should not be capitalized.
- e.g. does not make sense here (e.g. == "for example"). I think maybe e.g. could be replaced by a semi-colon (;).
- At the end of the line, it should say "an existing" ("an" is missing).
- The line goes longer than 80 characters, and needs to be wrapped.
Comment #15
salah1changes made. Thanks
Comment #16
jhodgdonThanks! Looks good except that there is an extra space at the end of this line:
Comment #17
salah1I removed the space. Take a look. Thanks
Comment #18
jhodgdonOne more thing, which changed since the last patch -- we need a space before the ( in:
* - vid: The ID of the vocabulary(omit if creating a new vocabulary; only
Comment #19
trogels CreditAttribution: trogels commentedreintroduced the space before the parenthesis.
Comment #20
trogels CreditAttribution: trogels commentedComment #21
xjmThanks @trogels! I reviewed the patch and it looks mostly correct.
This comment looks correct to me. However, our API documentation standards indicate that optional parameters should have (optional) before the description and after the key name. Reference: http://drupal.org/node/1354#lists
Let's create a new patch with the
(optional)
in addition to the current comment change.Comment #22
trogels CreditAttribution: trogels commentedI see. It's fixed. I included an interdiff aswell and wrapped the line since it exceeded 80 characters.
Comment #23
xjmThat's the correct fix. Thanks!
Comment #24
Dries CreditAttribution: Dries commentedThank you. Committed to 7.x.