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.
Drush9 does not support old style hooks. See https://weitzman.github.io/blog/port-to-drush9
Done:
- Adds the drush.services.yml and composer boilerplate.
- Adds a new DrushCommands class.
- Registers the new options, replacing hook_drush_help_alter().
- Makes the kint() dumps work for the migrate:import commands.
ToDo:
- Release 8.x-2.x branch
- Make the migration rebuilds work.
- Maybe combine the EventSubscriber and Drush commands in a single class?
- move preMigrateStatus() the new Drush 9 command hooks.
- move preMigrateImport() the new Drush 9 command hooks.
Comment | File | Size | Author |
---|---|---|---|
#6 | migrate_devel-drush9-2938677-6.patch | 5.47 KB | andrewmacpherson |
Comments
Comment #2
mpp CreditAttribution: mpp at AmeXio for District09 commentedAt the moment these hooks are used:
hook_drush_help_alter
&hook_drush_command_alter
.The proper way to do this with Drush 9 is probably to extend from MigrateToolsCommands. See my and Moshe's comments on the blog:
Comment #3
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commentedThanks for the request.
Willing to accept patches for this. I would work on it but I haven't done much Drupal (or migrate) work.
Comment #4
aburrows CreditAttribution: aburrows at DigiDrop commentedI'm happy to write a patch for this, if it will help others / become co-maintainer as we're doing a lot of migrates now and would be good to have something that we use which can help others. We do use xdebug normally but its a nice thing to have with drush.
Comment #5
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commentedSure if you want to provide a patch and want to help maintain (And hopefully make better with other features) I'd be glad to add you as a co-maintainer.
Comment #6
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedI started porting this to Drush 9. This patch:
The tricky part was checking the Drush options in the EventSubscriber. Drush 9 doesn't have a global where the command options are available. I chatted with Greg Anderson (a Drush maintainer) on Slack and we came up with the idea of temporarily storing the command options with State API, so they could be read by the EventSubscriber.
Still TO DO:
This would remove the need to use State API, but would kinda violate the single-purpose SOLID principle, and it wouldn't be clear which namespace the class should live in.
Comment #7
greg.1.anderson CreditAttribution: greg.1.anderson at Pantheon commentedIf you want to use a global rather than replicating all of the options, there actually is a way to do that. The parsed options are available in the config object. You can see what's in the config object via:
You can look at one option via:
Comment #8
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedAha, thanks. I see the runtime options and args arrays in the output of
\Drush\Drush::config()->export();
Comment #9
greg.1.anderson CreditAttribution: greg.1.anderson at Pantheon commentedIf you want to log something to the console, there's
\Drush\Drush::logger()
.Comment #10
cferthorneyThis patch is working as expected and allows me to use `--migrate-debug` etc with Drush 9. Awaiting 1 more for RTBC.
Comment #11
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedNo, it still needs work.
The only functionality that has been ported, so far, is the visible debug output.
The migration config reset feature hasn't been ported yet. The patch contains some @todo tags.
Comment #12
cferthorney@andrewmacpherson, my apologies I'll review the code more thoroughly and see if I can help.
Comment #13
botris@andrewmacpherson is it possible to release a dev version with this patch in a 8.x-2.x branch? I'm happy to take on one or two features mentioned throughout this post, but am afraid of on big patch trying to do all.
Comment #14
botrisComment #15
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented@botris, Of course, but the project maintainer needs to do that..
Comment #16
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented@botris thanks for updating the task list.
Comment #17
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commentedThanks for the work guys, will get this released in a branch either tomorrow or next week.Sorry, I mean't to be responding to #3021648Comment #18
jcmartinezThis command used to run on Drush 8
drush -l mysite.com mim --migrate-debug --limit=1 --update custom_product_image_step1
I have applied patch #6 with Drush 9 and I get this error:
Comment #19
xurizaemonHey @jcmartinez! I've been caught out by that before - what you're seeing is likely the parameter order, and not specific to migrate_devel or this patch. I think Drush 9 is more specific about order of params.
Try
drush -l example.com mim custom_product_image_step1 --migrate-debug --limit=1 --update
instead?Seems like the migrate:import parameters need to come after the migration name.
Comment #20
jcmartinezHey @xurizaemon
You are totally right. Changing the order works!
Comment #21
Marijn82 CreditAttribution: Marijn82 commentedHello
I have applied the patch: migrate_devel-drush9-2938677-6.patch but still get no --migrate-debug or --migrate-debug-pre when I execute
drush migrate:import --help
Some details of my installation:
Drupal version : 8.8.1
Site URI : http://default
DB driver : mysql
DB hostname : localhost
DB port :
DB username : drupal
DB name : drupal
Database : Connected
Drupal bootstrap : Successful
Default theme : ji_theme
Admin theme : seven
PHP binary : /usr/bin/php7.2
PHP config : /etc/php/7.2/cli/php.ini
PHP OS : Linux
Drush script : /usr/local/bin/drush
Drush version : 9.7.1
Drush temp : /tmp
Drush configs : /home/vagrant/.drush/drush.yml
/var/www/drupalvm/drupal/vendor/drush/drush/drush.yml
/var/www/drupalvm/drupal/drush/drush.yml
Install profile : standard
Drupal root : /var/www/drupalvm/drupal/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : sites/default/files/tempy/
Can anyone help?
Thanks
Marijn
Comment #22
fabienlyHello for the record, I try to apply the patch but it dont applied. I am using drush 10 :)
edit : But the debug plugin works and it's still some help :)
Error log :
This is my rush status :
Comment #23
Ericmaster CreditAttribution: Ericmaster as a volunteer commented@fabienly I got pretty much the same setup and had no problems in applying the patch. I use a lando based setup btw.
Comment #24
marvil07 CreditAttribution: marvil07 at Adapt commentedI have been using this patch for a while, marking it as RTBC.
Comment #25
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #26
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #28
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedI've been added as a new maintainer for the module, and I've been working on this today.
I didn't commit my old patch from #6 verbatim. Instead I realized there were ways to simplify it.
Re. #7 & #8 - I figured out that I could detect this module's options in an event subscriber by using
\Drush\Drush::config()->get('runtime.options')
. That's great; it's no longer using State API to keep track of the options passed to Drush, which felt clunky and fragile.The commits here make the
--migrate-debug
and--migrate-debug-pre
work for thedrush migrate:import
command, like patch #6 did. In the interest of getting an alpha release of the 8.x-2.x branch out ASAP, I'm narrowing the scope of the issue to fix those only.I've manually tested the extra options for
drush migrate:import
using:NOTE: It doesn't work with Migrate Run 8.x-1.0-beta4 (released a few days ago). This is unrelated to the changes here. I filed #3151036: migrate_run 8.x-1.0.0-beta4 not working in Drupal 8.9 in the Migrate Run issue queue.
The migrate reset and config reset features (
drush migrate:status --migrate-debug
) have NOT been ported to Drush 9 yet. I'm still pondering that, and may address it in a follow-up.Comment #29
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedSome issue credits. These people moved the issue forward in a significant way:
Comment #30
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedUpdating title to reflect the scope.
Comment #31
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #32
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedComment #34
freed_paris CreditAttribution: freed_paris commentedHello,
I can't apply patch :
Any idea ?
Frédéric
Comment #35
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented@freed_paris:
If you are using the 2.0.x branch of migrate_devel, you don't need the patch, because that branch is compatible with Drush 9+.
The output you posted comes from running
composer install
, and trying to apply the patch usingcweagans/composer-patches
. It shows you are installing migrate_devel 2.0.0-alpha2, and trying to apply patch #6 from this issue.Try these steps:
composer require drupal/migrate_devel:^2.0
Comment #36
andres.torres CreditAttribution: andres.torres commentedHi,
Issue still need to be reviewed. I just installed a fresh Drupal 9.2.6 install along with migrate_devel 8.x-2.0-alpha2, devel 4.1 and issue persists with latest Drush 10.6.0. Tried applying the patch but the error is the same with or without the patch.
Comment #37
BThiemeNatlaw CreditAttribution: BThiemeNatlaw commentedThis issue still needs to be reviewed. We are attempting to migrate a large site from Drupal 7 - Drupal 9, and are on a fresh Drupal 9.4.7 install along with migrate_devel 8.x-2.0-alpha2, and the same issue persists with Drush 11.4.0. Has anyone found a solution? This bug makes the module essentially useless.
Comment #38
xurizaemonHi @BThiemeNatlaw
I think it's that the release installed on that site was generated a few days before the commit in this issue was landed.
- 8.x-2.0-alpha2 is dated 23 June 2020.
- Commit fixing this issue was 27 June 2020.
Try
composer require 'drupal/migrate_devel:2.x-dev@dev'
(or something like that), and see if the issue is resolved please?There are many benefits to publishing a stable release for a project. There may be things we can do to support an updated release of Migrate Devel, which might in turn reduce the number of people bumping on that issue you appear to have hit.
Practically, I think we largely use Migrate Devel on the 'dev branch' (eg some 2.x-dev build, likely pinning to a specific point to avoid surprises). Since it's a development tooling module, sites may opt to be more tolerant of a dev release.
(There is an issue template for requesting a stable release of a module over in #3239062: 'Stable Release Request' Issue Template which you might find helpful too.)
Hope this sorts it out for you!