Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 299205

taxonomy_term_save not creating with vocab machine name

$
0
0

Have tried running this in an update hook, as well as via /devel/php, in both cases it failed.

Essentially, the taxonomy_term_save() function creates a term (as the name suggests) in the specified vocabulary. The vocabulary is supposed to optionally take the vocabulary ID or the vocabulary machine name. However, it currently only appears to work with the ID.

<?php
// this successfully inserts the term, but into a non-existent vocabulary with VID 0.
$res = taxonomy_term_save((object)array('name'=> "Test Tag", 'vocabulary_machine_name'=> "tags"));
// this successfully inserts the term, into the Tags vocabulary as expected.
$res = taxonomy_term_save((object)array('name'=> "Test Tag", 'vid'=> "1"));
?>

The attached patch attempts to solve this. Note: regrettably I'm not a regular bug fixer/drupal core contributor, so this may be better solved in one of those presave invokes or something.


Viewing all articles
Browse latest Browse all 299205

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>