Allow developers to expose more configuration in the migrate form

Created on 7 June 2021, over 3 years ago
Updated 18 September 2024, 3 months ago

Problem/Motivation

At the moment, Migrate Source UI exposes one migration property at the form - File path. However, in our project, we'd like to make configurable something else. We'd like to extend the basic form, add one more form element and pass a selected value into the migration plugin definition (for example, as a constant) so we can use it inside the migration.

Currently, it's complicated and requires many things to change/extend, but it can be much simpler.

Proposed resolution

The initial idea is the following:
1) Pass these options as source plugin configuration (so it'll be applied automatically in Migration constructor);
2) Move options definition into another protected method, so it can be easily overridden;

Also, I think we can try to remove \Drupal\migrate_source_ui\MigrateBatchExecutable because it looks very similar to Drupal\migrate_tools\MigrateBatchExecutable and it's hard to maintain the same state between both classes.

For example, the migrate source batch is losing an important feature that was added to migrate_tools here: #3145997: Support passing $options['configuration'] to batch callback β†’ .

Remaining tasks

1) Accept #3217651: Allow passing migration configuration into MigrateBatchExecutable β†’ ;
2) Review and commit the merge request;

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Matroskeen πŸ‡ΊπŸ‡¦ Ukraine, Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom welly

    Having tested this recently, the changes made in the merge request work well and I'm able to expose additional config in the migrate form (I'm currently also overriding the MigrateSourceUi form class).

    I've created a backport patch for RC1 (as that's the version I'm currently using) but happy to help out moving this ticket along. Is there anything specific that needs doing?

  • πŸ‡¬πŸ‡§United Kingdom welly

    Previous patch didn't apply for some reason. Let's try this one

  • πŸ‡¬πŸ‡§United Kingdom welly

    And a patch for the latest version

  • πŸ‡¬πŸ‡§United Kingdom welly

    $options['update'] should be an int not a bool.

  • πŸ‡¬πŸ‡§United Kingdom welly

    Just to note I'm creating these patches so we can apply them as standard in our composer workflow :) Let me know how we can get this issue over the line and merged. This is a pretty important bit of work for a project! Cheers!

  • Pipeline finished with Skipped
    5 months ago
    #228138
  • Status changed to Fixed 5 months ago
  • πŸ‡¬πŸ‡§United Kingdom welly

    Yeah! Thanks for this!

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

  • πŸ‡ΊπŸ‡ΈUnited States caesius

    I have a migration that breaks after updating to the latest version of Migrate Source UI which I traced to this change. Does this update require updating configuration for old migrations?

    What happens is that existing content gets overwritten exactly as intended by the source ID (here called MatchKey), however items new to an import do not get imported due to this error:

    Migration failed with source plugin exception: 'MatchKey' is defined as a source ID but has no value.

    I believe removing the Migrate Source UI version of MigrateBatchExecutable causes the migrations to use the Migrate Tools version of the same class, which for whatever reason does not work with the code or configuration used for our migrations. We're using the latest version of Migrate Tools.

    I looked through the release history and issue queue for Migrate Tools but couldn't find any indication of what updates need to be done.

    I'll try to debug this more and may split off a new issue to the effect of "Document this breaking change" but wanted to flag this to the people who worked on this update.

Production build 0.71.5 2024