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

joachim’s picture

Another very handy use cases would be taxonomy term reference fields where no term is found -- in essence, where source data gets dropped.

moshe weitzman’s picture

Category: feature » support
Status: Active » Fixed

Did 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.

joachim’s picture

Status: Fixed » Active

That 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:

    migrate_ui_capture_message("I like cake!", 'success');
    self::displayMessage(t('I really like cake a lot!'), 'success');

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.

mikeryan’s picture

To save messages in the message table, use Migration::saveMessage(). There are a number of examples among the destination plugins.

joachim’s picture

Title: add a persistent log system » document the persistent log system
Category: support » task

Aha! 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!)

mikeryan’s picture

Component: Code » Documentation
Priority: Normal » Minor
joachim’s picture

What'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.

mikeryan’s picture

That'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:

  Migration::setDisplayFunction('migrate_ui_capture_message');
pifagor’s picture

Issue summary: View changes
Status: Active » Closed (outdated)