The hs_taxonomy_hierarchical_select_create_item() function assumes that the only return value from taxonomy_term_save() that indicates success is SAVED_NEW. Normally, this is a safe assumption, but if a third-party module customizes the term saving process, it's possible for SAVED_UPDATED to be returned instead.

According to the docs for drupal_write_record(), which is what taxonomy_term_save() uses to write out records, a better way to check for success is to see if the return code is not strictly FALSE.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GuyPaddock’s picture

The attached patch should correct the issue described.

GuyPaddock’s picture

Status: Active » Needs review

Setting to NR.

stefan.r’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

6.x issue without activity for over 3 years, closing.

Please reopen if this is still an issue in 7.x.

stefan.r’s picture

Status: Closed (won't fix) » Closed (fixed)

Oops, this is actually a 7.x issue! Re-rolled and committed this as:

@@ -744,7 +744,7 @@ function hs_taxonomy_hierarchical_select_create_item($label, $parent, $params) {
 
   $status = taxonomy_term_save($term);
 
-  if ($status == SAVED_NEW) {
+  if ($status !== FALSE) {
     // Reset the cached tree.
     _hs_taxonomy_hierarchical_select_get_tree($params['vid'], 0, -1, 1, TRUE);