Closed (cannot reproduce)
Project:
Migrate
Version:
7.x-2.5
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Mar 2013 at 15:51 UTC
Updated:
16 Apr 2013 at 14:08 UTC
I have a got feature setup that defines a migration. This works very well and I can succesfully run the migration after installing the feature.
I would like to automatically run the migration when the feature is being installed. I wrote the following install file for it:
/**
* Implements hook_install().
*/
function feature_front_install() {
MigrationBase::registerMigration('FrontBlocks', 'FrontBlocks', array('class_name' => 'FrontBlocks'));
MigrationBase::registerMigration('FrontPageItems', 'FrontPageItems', array('class_name' => 'FrontPageItems'));
$migration = Migration::getInstance('FrontBlocks');
$migration->processImport();
$migration = Migration::getInstance('FrontPageItems');
$migration->processImport();
}
/**
* Implements hook_uninstall().
*/
function feature_front_uninstall() {
$migration = Migration::getInstance('FrontBlocks');
MigrationBase::deregisterMigration('FrontBlocks');
$migration = Migration::getInstance('FrontPageItems');
MigrationBase::deregisterMigration('FrontPageItems');
}
The install hook runs and starts the migration. But the problem is that only the title field for the imported nodes gets saved. All other fields are ignored.
When I then run a "drush mr FrontBlocks" and "drush mi FrontBlocks" all the fields are there.
What am I doing wrong here?
Comments
Comment #1
mikeryanTough to say - are the fields that are not being imported defined in the same feature? It may be that they haven't yet been set up when the install hook runs. Also, I don't think Drupal does a full bootstrap by default for install hooks - you might try a drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL).
Comment #2
weseze commentedI've tried moving the import to another feature so that I'm 100% sure the content type and fields were created in a feature installed before it. Didn't help...
I'll try the bootstrap suggestion, although I'm not getting my hopes up because the documentation states that:
Have you personally done something like this before and succeeded?
Comment #3
mikeryanI have not heard of anyone attempting to run migrations in an install hook before, you're a trailblazer;).
I would debug by running your module installs from drush, with some drush_print's and drush_print_r's in prepareRow, prepare, complete to figure out where the disconnect is - is the source row not getting properly populated? Are the field mappings not being applied? Are the field handlers not building the field arrays for them?
Comment #4
mikeryanNo further information provided.
Comment #4.0
mikeryantypo