Download & Extend

weird issue with hook_migrate_destination_prepare_node()

Project:Migrate
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I have a weird issue in hook_migrate_destination_prepare_node(). I have code like:

  if ($node->type == 'education_resource') {
    // Map each node to its taxonomy terms.
    $terms = array();
    $result = db_query("SELECT c.catName FROM {donations_module_edu_map} m, {donations_module_edu_cats} c WHERE m.idResources = %d AND c.idCategory = m.idCategory", $row->idResources);
    while ($term = db_fetch_object($result)) {
      $terms[] = $term->catName;
    }
    $vid = db_result(db_query("SELECT vid FROM {vocabulary_node_types} WHERE type = 'education_resource'"));
    $vid_key = 'migrate_taxonomy_' . $vid;
    $node->$vid_key = implode($multiple_separator, $terms);
 
    // Other processing.....
  }

Basically it looks for terms associated with the node and populates the appropriate node object. The taxonomy terms have already been migrated over, and I'm doing this for a few content types.

If I migrate one content type at a time (ie one content set per batch run), then all the taxonomy terms are correctly associated with the nodes.

However if I migrate all node content sets in one batch run, then the taxonomy terms for the last content set are never associated with the nodes, despite the fact that the taxonomy terms for the other content sets in the batch appear, and despite the fact that processing the content set by itself also works.

I've put in drupal_set_messages() in hook_migrate_destination_prepare_node() and can confirm that $node->$vid_key is being set correctly, as is $vid_key. Right now it looks like something weird is happening within the migrate module itself.

Any ideas?

Comments

#1

Oh I should add that the other processing that takes place in hook_migrate_destination_prepare_node() works in all instances, regardless of whether the content set is processed as part of a batch or individually. Perhaps it's something specific to 'migrate_taxonomy_$vid'?

#2

Status:active» needs review

I tracked it down to a static $vocabs; issue. The attached patch addresses the issue.

Cheers,
Stella

AttachmentSize
541700.patch 1.03 KB

#3

Status:needs review» fixed

Committed, thanks!

#4

Status:fixed» closed (fixed)

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