Needs work
Project:
Drupal-to-Drupal data migration
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Sep 2014 at 19:55 UTC
Updated:
27 Mar 2018 at 20:03 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
roberttstephens commentedIt's not a clean way, but you can
1) Extend the drupal 7 node class.
2) Update the migrate_status table to use your new class.
You could extend MigrateD2DWizard and override function reviewForm instead, but that looks like it would duplicate a lot of code. If you do that, you would also have to do something like the following.
I think the "right" way would be to add a form element to the UI to select which class to use for a given migration.
Comment #2
joachim commentedMarked #2335599: Allow other modules to add extra steps to a wizard as a duplicate.
Comment #3
joachim commented> 1) Extend the drupal 7 node class.
That won't work if more than one contrib module is in play!
Presumably this use case is covered in D8, because Migrate in D8 core is based on plugins and config files, and any module can provide them.
So I think that for D7 we need to invent something.
What about allowing extra wizard steps to be provided by other classes, and declared with the migrate info hook?
Comment #4
fengtanOr maybe we could use a hook ? Patch suggestion attached.
Comment #5
joachim commentedWould be better to do this in Migrate, so that any wizard can take advantage of this?
Also, there's the matter of the order of steps that get added. In the Image module use case, we have two submodules: Image and Image Attach, and one needs to go after the other. I guess each module can use addStep(), and they should know their relative module weights and so act accordingly?
Comment #6
joachim commented> Would be better to do this in Migrate, so that any wizard can take advantage of this?
On second thoughts, that's maybe not such a good idea:
- D2D is the major use case for another module altering a wizard. (I've written several custom migration wizards and never needed something like this.)
- putting it in Migrate would mean the hook implementations would need to check the wizard class to decide whether to act, which would add code to all the D2D implementations.
Comment #7
joachim commentedActually, I don't think the alter hook as it stands is going to work.
I'm trying to implement it, and I immediately hit a problem when trying to add extra steps: addStep() expects as a parameter the name of a method on the wizard class. Passing in a PHP callable instead won't work because the base Wizard class does this:
Comment #8
joachim commentedThis gets more complicated the more I look at it :)
- addStep() needs to be able to accept a callable as well as a method name
- addStep() needs to be changed to a public method
- the wizard form builder needs to work with a callable for the form step builders
- the wizard needs a method that returns all its current steps, so code that seeks to extend the wizard can pass an $after step to addStep()
- for D2D, the reviewForm() method needs to allow extension so that the extra contrib steps can also be reviewed.
I'm working on something and will file a patch at #2363015: Add ability for other modules to alter a migration wizard.
Comment #9
joachim commentedI've posted a patch to Migrate at #2363015: Add ability for other modules to alter a migration wizard.
This is a patch on D2D which builds on top of that.
I'm making use of this in Image module's migration to D7 -- I'll be committing code to that module soon.
Comment #10
mikeryanPending the latest version of #2363015: Add ability for other modules to alter a migration wizard - I don't see that any changes to migrate_d2d_ui are necessary here, the review form should be alterable by the standard hook_form_alter().
Comment #11
joachim commentedWill a hook_form_alter() be able to grab the right wizard extender from the wizard in the form? It'll also have to read out its properties, which means the extenders either need an all-purpose accessor method or to make those properties public.
It does strike me as better DX to be able to keep the logic for the review form inside the same class as the rest of the wizard logic, rather than have it live in another function, in another file.
Comment #12
joachim commentedAlso, without my proposed reviewAlter() method, how do extenders add migrations? It doesn't make sense to add this in the validation methods, as the user might step backwards and forwards in the wizard, and you could end up with a total mess -- migrations added multiple times, and so on.
Though this does suggest that this should be done at the Migrate level rather than here, but the Migrate wizard class doesn't provide the concept of the final review step, does it?
Comment #13
mikeryanWhat I'm working on, both so I get a good feel for exactly how modifying the wizard will work, and to provide an example to help others, is an add-on module to migrate Drupal 6 aggregator configuration (and maybe if ambitious, the imported items) to Drupal 7 feeds_news. I'll see if it is possible to do this with existing APIs without too much trouble, or if we do need to add reviewAlter() or something like that.
On stepping backwards and forwards, that's already an issue, I'll deal with that in #2390149: Make sure back-and-forth in wizard works properly. If an extender adds their migration in the review step, it should all just work fine.
[edit: fixed issue reference]
Comment #14
mikeryanOK, I've got a POC which I think works nicely - I haven't actually implemented the migration itself, but have verified that the review form is updated according to the selection in the added step. This works without making any changes to migrate_d2d at all, and with one change to MigrateUIWizard to add an extender getter (I'll put an issue in the Migrate queue for that).
feeds_migrate_aggregator.module:
feeds_migrate_aggregator.migrate.inc:
Comment #15
mikeryanSee #2331681: Document extending D2D migration to allow contrib modules to add wizard steps - for a form_alter hook to be able to invoke an extender, the wizard class needs to expose its extenders. Adding method getExtender($extender_class).Bah - swapped tabs and wrote this in the wrong place.
Comment #16
mikeryanComment #17
joachim commentedHmm, the whole of that feeds_migrate_aggregator_form_migrate_ui_wizard_alter() is going to have to be copy-pasted by all other contrib modules -- it's just boilerplate.
Comment #18
mikeryanIt wouldn't be identical in all use cases, I would imagine there would frequently be other parts of the wizard besides the review form being altered. Bottom line, building a distinct alter mechanism into migrate_d2d doesn't add functionality, it's simply a convenience to save a few lines in hook_form_alter() - I don't think it's worthwhile.
Comment #19
michaelmallett commentedHow can I help document this? I've spent a very long time delving through these modules so I can use it extend the wordpress_migrate module, and I'd like to write it down!
Comment #20
sw_msnd commentedHelp! I am a novice at drupal migration, I am trying to use the drupal2drupal migration feature of the migrate module. I have a database sitting on a different apache webserver, and I am able to connect to it remotely using mysql workbench from my local machine. I have a fresh drupal install on a new webserver and am attempting to use the migrate_d2d wizard, but I keep getting the following error when trying to connect to my remote database:
"Failed to connect to source database, message returned: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)" Can I actually do this? Also, I have verified my connection information for the remote mysql database.