I'm not sure if this is a bug or a behaviour that needs to be documented.
I'm trying to use preImport(), postImport(), and complete() to log import details to a log file. preImport() initializes some variables, including the log file name, complete() adds a log entry to an array, and postImport() writes the array to the log file.
When I run an import from the UI it produces a running status of the items processed, typically every 150 to 200 items. It appears that preImport() and postImport() are called when each status message is produced, not at the very beginning and end of the entire import process. I've found I get a log file that corresponds to each status message.
I suspect the import is being handled in batches, and that preImport() and postImport() are called for each batch. The naming of these methods implies (to me at least) that they bracket the entire import, not the individual batches, so I find this behaviour surprising.
Is this a documentation issue or a bug in the implementation of preImport() and postImport()?
If this is the intended operation of preImport() and postImport(), is there a set of methods called at very beginning and end of an import sequence?
Thanks.
Comments
Comment #1
mikeryanReason #12a to use drush rather than the UI to run migrations;). Yes, the UI uses the Drupal batch API, and each batch is a fresh migration run so invokes preImport() and postImport(). We should clarify that they are called once per invocation of a migration.
Comment #2
dale42I've updated the documentation at "Less commonly implemented Migration methods" http://drupal.org/node/1343112
Comment #3
mikeryanGood, thanks!