Closed (fixed)
Project:
Migrate Upgrade
Version:
8.x-3.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Nov 2019 at 10:52 UTC
Updated:
18 Feb 2021 at 06:47 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heddnLovely to see someone happy to push forward a Drush 10 patch. Please throw up patches :)
Comment #3
mradcliffeThis isn't a complete patch, but it's a start to maybe inject LoggerChannelFactoryInterface and then LoggerChannelInterface into MigrateUpgradeCommands and MigrateUpgradeDrushRunner respectively. The latter doesn't have a service since the upgrade commands acts like a factory. For bc, I added \Drush\Drush::logger(), which is also deprecated, into the migrate upgrade drush include file.
Not sure if this works at all at the moment, but might as well upload and see. Marking as Needs work.
Comment #4
poker.ca commentedAfter applying patch (#3) I get the following error on running the command:
$ drush migrate-upgrade --legacy-db-key upgrade --configure-only
[error] ArgumentCountError: Too few arguments to function Drupal\migrate_upgrade\Commands\MigrateUpgradeCommands::__construct(), 1 passed in /var/www/drupal8/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 269 and exactly 2 expected in Drupal\migrate_upgrade\Commands\MigrateUpgradeCommands->__construct() (line 42 of /var/www/drupal8/web/modules/contrib/migrate_upgrade/src/Commands/MigrateUpgradeCommands.php) #0 /var/www/drupal8/web/core/lib/Drupal/Component/DependencyInjection/Container.php(269): Drupal\migrate_upgrade\Commands\MigrateUpgradeCommands->__construct(Object(Drupal\Core\State\State))
NB: Using Drupal/Core version 8.7.10, Migrate_upgrade 8.x-3.1, and Drush 10.0.2.
Comment #5
wim leersConfirming this is still a problem.
Comment #6
wim leersAfter a lot of trial and error and grepping the Drush code base (because if Drush has documentation for how to upgrade from deprecated code paths to new code paths, I couldn't find it), it turned out to be pretty simple. And #3 was already super close :)
Comment #7
mradcliffeThank you for fixing up the patch!
Do we need to fix this as well to be a direct mock of Drush\Log\Logger? I guess if it passes test, then no.
Comment #8
mradcliffeChanged to Needs work based on test bot results.
Optional arguments should be at the end, but I don't think we can change the order. So maybe Logger should be NULL and then add NULL checks?
Or if we can change the arguments of the runner, then we can swap these around. That would also require updating all the calls to MigrateUpgradeDrushRunner.
Testbot mentions an unused use statement. I think this is the one.
And this probably should be updated to
\Drush\Log\LoggerMy bad code. I assigned $loggerProphet to a local variable and then try to use it as an object property.
Comment #9
poker.ca commentedThank you -- patch #6 did the trick. All good now.
Comment #10
wim leersI think this is preferable :) I don't think we need to provide backwards compatibility here.
Want to address your own feedback? I'm happy to review & RTBC!
Comment #11
mradcliffeSure. I found that in #3 I needed to typehint to the PSR interface because Drush\Log\Logger doesn't implement LoggerChannelInterface.
Let's see if this passes on the test bot.
I think this is probably Major now that 8.8.0 is released.
Comment #12
mradcliffeAt least the tests are running now for the patch!
Type probably needs to be \Psr\Log\LogInterface in the function definition as well to both fit Drush\Log\Logger and LoggerChannelInterface. I think Drush's DrupalLogAdapter does some sort of handling to transform Drupal's logs?
Comment #13
mradcliffeI tried to look into doing a bit more of a functional test in the DrushTest rather than mocking it, but I think that's not possible without actually having Drush around to add its DrupalLogAdapter as an available logger. "ok" level is only available when using drush and not in core, but "success" should only be used once per drush command.
This patch changes the typings of Drush\Log\Logger to the generic Psr LoggerInterface.
Comment #14
heddndrush 10 should be available, at least on the testbot. See https://git.drupalcode.org/project/migrate_upgrade/blob/8.x-3.x/composer...
Comment #15
heddnmigrate tools has more fully-baked test coverage using the same dependencies. See https://git.drupalcode.org/project/migrate_tools/blob/8.x-4.x/tests/src/... as an example.
Comment #16
mradcliffeOh, nice! Thank you, @heddn. I think a new browser test like that would probably help raise confidence in the patch to make sure that Drush's Logger is being used appropriately.
Comment #17
heddnI think this test will fail miserably, but its what I got to in the time I had. Perhaps it will let the next person move it along further.
Comment #18
quietone commentedTested this patch using the core D7 source fixture as the source, minimal D8 install, enabled the necessary modules.
Comment #19
heddnA quick fix for #18. Doesn't fix any of the tests. That will have to be another day or someone else.
Comment #20
berenddeboer commentedComment #21
heddnNW because tests are still failing.
Comment #22
mmekutAfter applying patch #19, 'drush rq' command crashes drush 10 with the following output.......
ArgumentCountError: Too few arguments to function Drupal\migrate_upgrade\Commands\MigrateUpgradeCommands::__construct(), 1 passed in /var/www/fading/afrocentric/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 269 and exactly 2 expected in Drupal\migrate_upgrade\Commands\MigrateUpgradeCommands->__construct() (line 42 of /var/www/fading/afrocentric/public_html/modules/contrib/migrate_upgrade/src/Commands/MigrateUpgradeCommands.php).
[warning] Drush command terminated abnormally.
Comment #23
mmekuttrying patch #6.................Patch does not apply as #19 covers and extends what #6 does
thanks @mradcliffe..................your suggestion made my day
Comment #24
mradcliffeI think your service container needs to be rebuilt. Try drush cr.
Comment #25
geerlingguy commentedJust noting that I bumped into this following the official Drupal upgrade migration guide on Drupal.org, which recommends installing Drush via composer (which currently gives 10.2.x), then installing the three required migrate modules, then running
drush migrate-upgrade. I had to Google the error message which eventually brought me here.Should we update the migration guide, for now, to specify Drush 9 when running the
composer requirecommand, since Drush 10 definitely won't work at all until this issue is fixed? Otherwise it's another frustrating bump in the road for users following the guide.Upgrade guide doc in question: https://www.drupal.org/docs/8/upgrade/upgrade-using-drush
Comment #26
ressaI have added a warning under https://www.drupal.org/docs/8/upgrade/upgrade-using-drush#s-installing-d....
Thanks for reporting this @geerlingguy. I am really looking forward to the next livestream in your Migrating JeffGeerling.com from Drupal 7 to Drupal 8 - How-to video series :)
Comment #27
benjifisherI am starting to look at this issue. Here are some initial questions/comments based on the patch from #19.
The changes to
composer.jsonare not a bad thing, but they seem to be outside the scope of this issue.This issue is about Drush 10, so it is surprising to see changes to this file. I guess these are needed because of the other changes in the patch.
(and similar changes elsewhere). The second argument of the constructor defaults to
[]. Why not use$runner = new MigrateUpgradeDrushRunner($this->logger)?I hope to have a more substantive comment and/or an updated patch within a week.
Comment #28
benjifisherI have spent more time than I can really afford trying to debug the test failure with the patch in #19. I do not have a solution, but here is what I found.
I added debugging code like
to the test classes (
migrate_upgrade/tests/src/Kernel/DrushTest.phpandmigrate_upgrade/tests/src/Functional/MigrateUpgradeCommandsTest.php). I added a similar line ("after" instead of "before") tomigrate_upgrade/src/Commands/MigrateUpgradeCommands.php.The kernel test passes. My debugging lines show similar "before" and "after" results: the same database keys are available before the test calls
MigrateUpgradeCommands::upgrade()and when that function executes.The functional test is the one that fails. The "before" debug output shows the expected database keys (including
migrate_drupal_ui), but the "after" result shows only thedefaultkey.Since
Database::getAllConnectionInfo()returns the value of a static class property, I think that a new PHP process (or thread or whatever) is being created, which means that the static property gets lost.The difference between the two tests is that the kernel test calls
MigrateUpgradeCommands::upgrade()directly, but the functional test usesDrush\TestTraits\DrushTestTrait::drush()to run the command.Comment #29
heddnLet's see if this gets us a little closer.
Comment #30
heddnComment #32
heddnComment #33
heddnYeah, the blocker in the test is now fixed. Just need to match up assertions.
Comment #34
heddnComment #35
heddnComment #36
heddnComment #38
heddnComment #39
heddnComment #41
heddnI'm confused as the failures surfacing on the test bot aren't surfacing on local. Meaning, the are green and I can't reproduce the failures. Will leave for now and hope someone else has suggestions.
Comment #42
heddnComment #43
heddnComment #45
benjifisherI get the same failures locally that the testbot shows.
I tried hacking the test, adding
I got output like
I also added
and got
It is a little disconcerting that the -/+ markers for Expected/Actual seem to be backwards, but this seems to be saying that
$this->getOutputFromJSON()really is an array with just 6 entries. Why only 6? Why these 6? Why the same 6 for the D6 test and the D7 test, includingupgrade_d6_upload_field?Maybe we are not connecting to the database we think we are connecting to. If I have time to work on this tomorrow, then I will explore that possibility.
Comment #46
benjifisherI did a little manual testing. I started by setting up an extra database and importing the fixture, following the instructions on Step 3: Create a database and Generating database fixtures for D8 Migrate tests:
Then I ran the
migrate:upgradecommand:I got many copies of the warning
but I figure that I can ignore those because I imported the D6 fixture.
Then I got the expected output: more lines than I care to count, but nothing for the
actionnorbookmodules. Then I enabled those modules and ran the command again. This time, the output (after the warning messages) started withThis is very different from the output I got last night when running the test. Perhaps I was right then, and we are not connecting to the correct database.
Comment #47
benjifisherI was right: adding this code
leads to this output when running the test:
I am using Lando, and that is the
db-urlto connect to the default database.Comment #48
heddnThanks @benjifisher. That makes sense and helps a lot. Here's another try. It passed green locally.
Comment #49
heddnRe-adding some drush 8 BC logic as it doesn't hurt and I'd like to keep support for it as long as possible.
Comment #50
heddnAnd here we re-add the export printing (in another location) for drush 8 continued support. I can't see anything else in my self-review.
Comment #51
uberhacker commentedDrush 10 is still not ready. Why is 8.x-3.1 green? The green version should be 8.x-3.0 because that actually works with Drush 9.
Comment #52
heddnI don't understand #51. Are we trying to say that you can't use Drush 10 on your site? Or... what. It isn't clear what is intended by Drush 10 not being ready. Because it is ready and 10.2+ is already released. And Drush 9 has only a few more months of support left on it.
Or are you saying that the patches here don't make the module support drush 10?
Comment #53
benjifisherThe patch in #50 is working well for me, but I have a few suggestions for cleaning it up.
As I said in #27, this is out of scope, but that is OK as far as I am concerned. I checked the links. I have not seen the
slackkey before, but that does seem like the primary form of support.The change record recommends the pattern
Maybe it is worth doing it this way.
In what sense is it "shared"? Maybe I have it wrong, but I think that Drush injects this class when we use a Drush command, and Drupal injects it when we run the unit test (not the functional test). If so, then it would be more accurate to say "A PSR-compatible Logger provided [or injected] by Drupal or Drush". Maybe "PSR-3 compatible".
The code looks reasonable, but I do not know the Drush output routines well enough to review the other changes in this file.
Same thing here. There have not been any changes to this file since at least Comment #19.
Nit: can we handle the parameters in the same order that they are defined?
I think we can go back to
Since the tests are so similar, can we combine them? We could use a data provider to supply the path to the fixture, the expected output (or not, since that dcoes not change) and so on.
Nit:
Since this method sets the
configure-onlyoption, I would call the methodconfigureMigrations()and change the one-line description to something like "Generate migration config[uration] entities".Nit:
I guess that long lines bother me more than most people. I prefer something like
I think this is the only remaining place where the constructor is called with the optional parameter explicitly specified.
Comment #54
heddnThanks for the review. I think this addresses all the review feedback in #53.
Comment #55
benjifisherWhy doesn't the testbot set the status to NW after "PHPLint Failed"?
This seems to be the problem (from the interdiff):
There is a stray space in the function name.
Comment #56
benjifisherWhy not simply
We want the values to be
6and7, not[6]and[7], right? Or maybe"6"and"7".Also, I snipped the doc block, but it needs an
@paramcomment.Comment #57
heddnre #56: I think we want it the way it is. The arguments for a data provider are an array of values. If we do it the other way, phpunit will fail and complain.
Fixed the php lint issue.
Comment #58
heddnComment #59
benjifisherThanks for the updates since my review in #53. I have a collection of nits and suggestions, but I will defer to you on the suggestions if you do not like them.
I think a corrected version of my suggestion in #56 is simpler:
Nit: the one-line description needs ending punctuation.
The
$optionsparameter should have an@paramcomment. Keep in mind the next point and your response.It seems inconsistent to let the calling function override
legacy-db-urlbut notlegacy-db-prefix. I might not allow either to be overridden. This snippet also removes the$urlparameter:Sorry, I forgot to look at this function in my earlier review:
In the one-line comment, I would use either
migrate_plusor "Migrate Plus".It looks as though the code comment about embedded data sources was copied from somewhere else.
I do not like the pattern of assigning
$migration_idand then conditionally reassigning it. We could use if … then … else or a ternary operator orFinally, if we replace
array_unique()witharray_flip(), then we could replace theforeachloop with an assertion thatarray_diff_key(...)is empty.Comment #61
heddnAddressed all the feedback in #59 and committed. Thanks for all the help on this one. Lots of good feedback to make things better.
Comment #62
uberhacker commented@heddn: Sorry for the late reply. My point was the 8.x-3.1 version of this module does not work with Drush 10 without patching so it shouldn't be marked green implying it is the "stable" version.
Comment #64
idebr commentedThis issue is mentioned on https://www.drupal.org/docs/8/upgrade/upgrade-using-drush, and recommends users to install drush 9 instead. I suppose that note can be removed when a new release is tagged?
Comment #65
ressaThanks to everyone for fixing this issue. Would a fresh release be worth considering? It seems like the exclude modules from the configuration synchronization feature introduced in Drupal 8.8 via something like this in
settings.php:$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];.... only works with Drush 10, which I would prefer, over the more complex solution Configuration Split offers.
Comment #66
heddnTests for the module are currently failing. Mainly because of core failures introduced by #2746541: Migrate D6 and D7 node revision translations to D8 and being fixed in #3125763: Hidden dependency on migrate_drupal from node module when only migrate.module is enabled. Once we can get non-failing tests again, I'm more then happy to release a new tag.
Comment #67
ressaThat sounds great @heddn, thanks! Both issues look epic with a lot of work getting done, so thanks also to everybody involved in these two other issues.
Comment #68
ressa#3125763: Hidden dependency on migrate_drupal from node module when only migrate.module is enabled was just committed and awaits back-porting, so one down, and one to go :-)
Comment #69
benjifisher#3125763 was committed to the 8.9.x, 9.0.x, and 9.1.x branches a little while ago.
#2746541 was committed to 8.9.x and 9.0.x more than two weeks ago. (Maybe that was before 9.1.x branched from 9.0.x.)
Both issues are now fixed on those branches. Both are waiting to be back-ported to 8.8.x.
Comment #70
solideogloria commentedCan someone provide a patch providing the fix that was actually committed? It looks like in #61 @heddn addressed some feedback and committed the code without a new patch.
Or is it safe to use patch #59 on the current tagged release?
Comment #71
ressaI just upgraded to the latest Drupal core and Migrate releases, and can confirm they work with Drush 10: