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.
Problem/Motivation
In #2876085: Before upgrading, audit for potential ID conflicts we needed to have access to the MigrationPluginManager inside Drupal\migrate\Plugin\migrate\id_map\Sql. To avoid a BC break, we used a singleton behind a protected accessor with a todo to resolve in 9.0.
Proposed resolution
Add the MigrationPluginManager by dependency injection.
Remaining tasks
Do it.
User interface changes
None.
API changes
The Sql class would have a new parameter to its constructor, the MigrationPluginManager.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#39 | interdiff-37-39.txt | 693 bytes | danflanagan8 |
#39 | 10.0.x-2919158-39.patch | 8.93 KB | danflanagan8 |
| |||
#39 | 2919158-39.patch | 12.22 KB | danflanagan8 |
Comments
Comment #2
maxocub CreditAttribution: maxocub as a volunteer commentedComment #3
heddnI don't think this is blocked any more.
Comment #4
maxocub CreditAttribution: maxocub as a volunteer commentedThis is a BC break so it will only be possible in 9.x.
Comment #6
xjmSince 8.9.x and 9.0.x are now in beta, I'm moving this to 9.1.x. Is there a way to make this change with BC/deprecation for the continuous upgrade path? Thanks!
The issue probably also does not need to be postponed since it doesn't appear to be postponed on anything specific. Marking active.
Comment #10
danflanagan8Here's a shot at taking care of this. This has an update to an existing Unit test so that it doesn't fail due to the missing service
plugin.manager.migrate
service. In normal situations there's not a BC problem. It's just the nature of unit tests.I ran
MigrateSqlIdMapTest
locally and it's passing. If the deprecation is as graceful as I think it is I wouldn't expect anything else to fail. But we'll see!Comment #12
danflanagan8Not too graceful apparently! This should be better.
Comment #13
mikelutzNeed to deprecate this for removal as well, rather than just deleting it.
Comment #14
mikelutzComment #15
quietone CreditAttribution: quietone at PreviousNext commentedHoping to nudge this along. Adding tag because this has deprecations for 9.4.
Comment #16
quietone CreditAttribution: quietone at PreviousNext commentedHad a coding standards errors, just ignore the patch in #15
Comment #17
mikelutzStill need to trigger a deprecation error in getMigrationPluginManager, I think, unless we are doing that automatically from the annotation now. I confess it's been a while since I've done a deprecation..
Comment #18
mikelutzComment #19
quietone CreditAttribution: quietone at PreviousNext commentedWriting the test for that took most of the time :-)
Comment #21
mikelutzLet's push to get this in 9.5. We try to avoid deprecations in X.last, but this class is not one that would normally be extended, so it should be fine.
Also, there is a replacement, `use $this-migrationPluginManager instead`
Comment #22
danflanagan8Here are the updates requested by @mikelutz.
Comment #24
danflanagan8Ugh. This patch changes the double quotes to single quotes so there's no interpolation in the deprecation warning.
Comment #25
Spokje*cough*
Still mentioning
is deprecated in drupal:9.4.0
*cough*
Comment #26
danflanagan8Oof. Thanks, @Spokje. Let's try this one.
Comment #27
mikelutzWe still need a test to trigger this deprecation
Comment #28
danflanagan8@mikelutz, I don't have a good reference for this claim, but deprecations related to new arguments in the constructor are not generally covered by automated tests. There are a handful of tests for stuff like that, but mostly not. I think we should be ok.
Comment #29
mikelutzHmm, I haven't heard of that policy change. I've always written a test when I've added parameters to a constructor.
I don't see an exception listed in the how to deprecate instructions, which are right below the list of what can be deprecated, which includes constructor parameter additions. I don't see anything either way in the specifc constructor parameter addition instructions, which isn't unexpected, none of the other sections really mention testing either. Is this the most recent deprecation policy, or is there another policy that I'm missing here?
Comment #30
SpokjeUnsure about any policy change on deprecations, but at the very least I think this issue needs a
10.0.x
patch, with removal of the deprecations made in the9.5.x
patch.Comment #31
mikelutzAgreed with @Spokje, though there is a chance the RMs might want to put this in the new 10.1.x anyway, so we should probably find out.
Comment #32
SpokjeSense = made.
Comment #33
danflanagan8Here's a new patch for 9.5.x that includes a test for the deprecation in the constructor. I'm also including a patch for 10.0.x with the deprecations removed.
Comment #34
danflanagan8@mikelutzt, @Spokje, any ideas on the custom commands failure in the 10.0.x patch in #33?
Comment #35
SpokjeI've seen it before, but never found out what's exactly wrong. I always blame it on the particular GitLab runner doing the test being wonky and retry, hoping it gets run on another one.
In the other retry there are real dragons:
Comment #37
danflanagan8That was all kinds of bad. This should be better. Apologies.
@mikelutz had too much faith in my abilities when he said in Slack:
I was right to try to get around doing this!
Comment #38
mikelutzLooking good, one nit:
This should return $this-migrationPluginManager. We've ensured it's initialized in the constructor to the service in the container, so no need to go back to the container again here.
Comment #39
danflanagan8I think that's a worthy nit, @mikelutz. Here's the updated patch for 9.5.x. I'm also re-posting the 10.0.x patch from #37 but with a new name, just to try to keep the most up-to-date patches in the same place.
Comment #40
mikelutzThanks. I tweaked the CR, lets get this in front of committers and hope they will allow a small deprecation like this in 9.5.
Comment #42
danflanagan8That recent fail was clearly unrelated to this issue:
Resetting status to RTBC.
Comment #44
danflanagan8Unrelated failure in
Drupal\Tests\book\Functional\BookTest::testGetTableOfContents
. Resetting to RTBC.Comment #45
alexpottDiscussed with @catch as we agreed that deprecating in Drupal 9.5 but marking for removal for D11 is the way to go here.
Fixed this on commit :)
Fixed this PHPStan error on commit. Nice catch PHPStan!
Committed and pushed 275a32813b to 10.1.x and abea4c7b5d to 10.0.x and 409a884bd7 to 9.5.x. Thanks!