Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I can show messages to the user during a migration run with migrate_ui_capture_message(), but these (AFAICT) are just shown as drupal messages when the batch process is complete.
It would be useful to have a more permanent log, for recording problems with the most recent run of a migration, eg:
- rows skipped due to bad data
- field values empty where not expected to be
This would go nicely together with the feature request #1152732: Define assertions on the data source.
Comments
Comment #1
joachim CreditAttribution: joachim commentedAnother very handy use cases would be taxonomy term reference fields where no term is found -- in essence, where source data gets dropped.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedDid you see the migrate_message_x tables? Those are persistent stores. These messages/errors are linked from the Migrate_UI dashboard page.
Reopen if this does not suffice.
Comment #3
joachim CreditAttribution: joachim commentedThat sounds like it would, but I'm not sure how to get messages into that.
What I've found in the example modules and the docs is these:
but both of them show a drupal_set_message-type message and after the import run, the 'Messages' column at admin/content/migrate/dashboard still says 0.
Comment #4
mikeryanTo save messages in the message table, use Migration::saveMessage(). There are a number of examples among the destination plugins.
Comment #5
joachim CreditAttribution: joachim commentedAha! Got it now.
Could this be added to the example migration classes, say in one of the prepareRow() methods in WineWineMigration? It's not currently in either of them (or the docs pages that I've read so far -- granted I've not read every single one!)
Comment #6
mikeryanComment #7
joachim CreditAttribution: joachim commentedWhat's the purpose of migrate_ui_capture_message()?
I've been using this for non-critical output that I don't need to save, but using it causes drush migrations to crash.
Comment #8
mikeryanThat's used by UI-based (Batch API) migration operations to pick up anything that would normally be displayed to the terminal with a drush-based migration, so it can be displayed when the next batch starts. It's not meant to be used from drush - I imagine it's crashing because the pages.inc file isn't going to be included from drush.
If you want to capture messages during a drush run, define your own function and set it as the migration display function as the UI does:
Comment #9
pifagor