I don't know if this is a bug or just a change in design. If the latter, I need to understand the change so I can fix my code.

Here's the important part of my code:

      $new_cat = $form_values['new_cat'];
      $term = array('name' => $new_cat,
         'description' => 'suggested by '. $user->name .' ('. $user->uid .') on '. date('F j, Y'),
         'vid' => $form_values['faq_vid'],
         'weight' => 0,
         'parent' => 0,
         'tid' => NULL,
         );
      taxonomy_save_term($term);
      $cert_tid = $term['tid'];

   $node = array(
      'type' => 'faq',
      'body' => '',    /* Empty string rather than null. */
      'title' => $form_values['title'],
      'taxonomy' => array($category => $term),
      'created' => time(),
      'uid' => $user->uid,
      'name' => $user->name,
      'status' => 0,   /* Unpublished. */
      'format' => 1,   /* Default filter (filtered HTML) */
      'comment' => variable_get('comment_faq', 0),
      );

    // Okay, let's get it done. Node_submit will prepare it and make it an object.
    $node = node_submit($node);
    node_save($node);

When the node is saved, taxonomy_node_save (line 690) tries to insert the nid, vid, and tid into term_node and gets a duplicate (key 1). This does not happen on 5.6.

Comments

nancydru’s picture

Category: support » bug
catch’s picture

Status: Active » Postponed (maintainer needs more info)

http://drupal.org/node/164532 - see the last few comments, the indexes were altered since RC2.

Please try again with HEAD.

nancydru’s picture

Hmm. How long before RC3?

I looked through the patch and there's not really any changes to term_node other than to delete some rows that I don't have.

When I create a new term and node, I'm getting the correct nid and vid set, but then it's creating term_node records with tid = 0, 1, AND the correct one.

nancydru’s picture

Nope, I found a fix, and I assume the problem: If you notice, $term is created as an array, not an object. Apparently this was okay in 5.x, but it's not in 6.x. I added a $term = (object)$term; and the problem went away.

nancydru’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
ordually’s picture

NancyDru, thanks much for posting your fix on this one in #4...I came across the same issue and your solution saved me a pile of time.