Follow-up from #2791041: Migrate source plugins should use dependency injection
They currently do not, and it causes a lot of weird acrobatics and unsavory hacking in Migrate's tests. The way around this problem, in my opinion, is the path through the jungle: add proper dependency injection to all Migrate source plugins in core and, ultimately, completely remove all mentions of \Drupal from SourcePluginBase and its many descendants.
This follow-up is to help smooth the way to the cleanup for D9 in D8 considering Migrate is in beta but Migrate Drupal is still in experimental.
This will only touch the parts in migrate_drupal
that are BC breaking considering it's in experimental
Comment | File | Size | Author |
---|---|---|---|
#19 | 2853647-19.patch | 18.51 KB | jofitz |
#19 | interdiff-17-19.txt | 1.18 KB | jofitz |
#17 | 2853647-17.patch | 17.98 KB | jofitz |
#17 | interdiff-16-17.txt | 804 bytes | jofitz |
#16 | 2853647-16.patch | 18.12 KB | jofitz |
Comments
Comment #2
joelpittetSplit the patch from the parent for migrate_drupal
Comment #4
jofitz CreditAttribution: jofitz at ComputerMinds commentedFix some (but probably not all) of the test failures.
Comment #6
jofitz CreditAttribution: jofitz at ComputerMinds commentedMop up a few more test failures.
Comment #7
phenaproximaNICE work! Self-assigning for review.
Comment #8
phenaproximaLooks good except for two type hints. However, I think this is going to need some major committer approval because it is a BC break. Even though DrupalSqlBase is technically experimental, a lot of source plugins scattered throughout core are extending it. It is heartening to see the tests pass, though, so maybe there's hope.
This should not carry the PHPUnit_Framework_MockObject_MockObject type hint. That's only used in testing.
Same here.
Comment #9
joelpittetRerolled without the typehint, thanks @phenaproxima
Comment #10
phenaproximaPatch lookin' good, but this will get kicked back for sure without a change record.
Comment #11
phenaproximaChange record written: https://www.drupal.org/node/2859980
Comment #12
mikeryanI think the change record needs some work - no one is doing "new DrupalSqlBase", but what they are doing is extending DrupalSqlBase as the node plugin in the patch does. Anyone with a source plugin extending DrupalSqlBase that implements __construct() and/or create() will need to make changes to accommodate this patch. Just showing the node plugin changes should address this.
I'm just a bit wary here - while migrate_drupal is alpha-experimental and thus *allowed* to make hard BC breaks, to approach stability we have tried to avoid those with real-world impacts, and this one will break real source plugins in the wild. I do think it's worthwhile, but just want to explicitly acknowledge that this is a bigger BC break as a practical matter than we've had for a while.
Comment #13
phenaproximaChange record updated with more detailed info, plus a list of plugins directly affected by this change.
I also acknowledge this is a major BC break, although an allowed one -- in my view it's better to get this done now, while we still can, and be finished with it. If the committers disagree, they can mark this for Drupal 9.x.
Comment #14
alexpottThe problem is migrate_drupal is not a regular experimental module. It would be wonderful if we could achieve this without breaking everything.
Shouldn't this just do
$plugin::create($container);
I don't get why we not adding the new params on the end? Especially as state is passed up to the parent constructor. But the other thing I don't understand it why we're adding dependencies here that the abstract doesn't depend on... oh I see it's because it does via
\Drupal\migrate\Plugin\migrate\source\SourcePluginBase
. Well that's not simple.I don't understand this change. This plugin is not dependent on either of the new dependencies as far as I can see. Oh same mistake as above - it is dependent just via
\Drupal\migrate\Plugin\migrate\source\SourcePluginBase
. Hopefully #2791041: Migrate source plugins should use dependency injection will make the injection all the way up to there.This assignment is is not required now right? In fact can't the entire constructor and create be removed?
Same here I think this can be removed.
Comment #16
jofitz CreditAttribution: jofitz at ComputerMinds commentedPatch in #9 no longer applies so re-rolled before addressing @alexpott's comments in #14.
Comment #17
jofitz CreditAttribution: jofitz at ComputerMinds commentedAddressing @alexpott's comments in #14:
Comment #19
jofitz CreditAttribution: jofitz at ComputerMinds commentedAddress test failures as a result of #14.1.
Comment #20
heddnThis probably won't see much attention at this point in the lifecycle of Migrate, since it requires a BC break with little value. To make that a little more clear, moving to 9.x.
Comment #21
heddnAnd postponing until we get closer to the date.
Comment #23
xjmThis would need to be done with BC/deprecation and would be a minor-only change. Since 8.9.x and 9.0.x are now in beta, I'm moving this to 9.1.x. Thanks!
Comment #24
xjmMarking active since it's not postponed on anything specific.
Comment #29
quietone CreditAttribution: quietone at PreviousNext commentedThere is a reroll over in #2791041-51: Migrate source plugins should use dependency injection, that has the migrate_drupal parts for this issue.
In #20, heddn commented "it requires a BC break with little value", therefore setting to postponed until discussed at a migrate meeting. I have added a comment to #3281351: [meeting] Migrate Meeting 2022-05-26 2100Z.