Problem/Motivation
The field migration plugin system hard-codes some plugin ID mapping in field migrations while an equivalent (and more maintainable) plugin system exists for the same reason.
This blocks #3202462: [PP-1] Provide option for contrib modules to map their D6 / D7 field formatter and widget plugin IDs to the equivalent D9 plugin ID and I also think it is only a leftover of times before the field migration plugin system.
Proposed resolution
Move the formatter and widget type mappings from the core formatter and widget migration plugin definitions into the corresponding @MigrateField
plugin.
d6_field_instance_widget_settings
d7_field_instance_widget_settings
d6_field_formatter_settings
(The d6_field_formatter_settings
migration does not contain hard-coded mapping.)
Retain the static maps in the d6 migrations to maintain BC.
Remaining tasks
- Make sure that the review in Comment #35 is addressed.
- Fix failing tests.
User interface changes
Nothing.
API changes
Nothing.
Data model changes
Nothing.
Release notes snippet
Issue fork drupal-3204212
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
huzookaComment #4
huzookaComment #5
huzookaThe last commit updates the
MigrationProvidersExistTest::testFieldProvidersExist
test with the new field migration plugins.Now imho this is ready for being reviewed by a maintainer.
Comment #6
huzookaComment #7
huzookaThe Drupal 6 part of the DateField field migration plugin still not works as expected.
Comment #8
huzookaComment #9
huzookaThis patch represents the state of the merge request in #7.
Comment #10
huzookaThis is a patch for drupal 9.1.x, without the tests.
Comment #11
Wim LeersJust did one more review, left a suggestion that should make it easier for next reviewers.
That being said, I 100% agree with
(from almost a month ago)
Comment #13
AnybodyGreat work @huzooka - just wanted to say THANK YOU for your migrate patches work done. Just ran into several of the issues you created patches on. Also of course thank you for your reviews @Wim! Confirming #11. Let's now wait for SSM review :)
Comment #14
quietone CreditAttribution: quietone as a volunteer commentedI started to review this today but have abandoned due to my frustration with Gitlab ignoring my clicks and not able to select multiple lines by dragging.
Overall, the patch looks good and nothing leaps out as a problem.
The title is very accurate and yet I'm changing it. Starting with 'convert' since that is what this is doing and then removing corresponding because to me that implies that the MigrateField plugin already exists, but in many cases they are being added.
I'll try to review again at the end of the week.
Comment #15
huzookaI agree with changing this to convert, but at the moment title suggests this is a D6-only migrate issue.
Comment #16
quietone CreditAttribution: quietone as a volunteer commented@huzooka, thanks for the correction. How about 'remaining'
Comment #17
quietone CreditAttribution: quietone as a volunteer commentedComment #18
Wim LeersDid you have more thoughts here, @quietone? :)
Comment #19
quietone CreditAttribution: quietone as a volunteer commentedNo, this fell off my list. But now, the MR is out of date, I can't apply it locally as I like to do.
Comment #20
Wim Leers… and apparently this causes "293 pushed commits" above, https://git.drupalcode.org/project/drupal/-/merge_requests/440/commits to say there's 141 commits when there's really still the same 5 and testbot to immediately conclude it's not mergeable.
No information about this at https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... sadly 😔
Comment #21
Wim LeersOMG!
Per https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/738 this is supported.
But on d.o, it looks like only the original creator of the merge request can edit the target branch 😬 For example, for https://git.drupalcode.org/project/ckeditor5/-/merge_requests/17 I have the "Edit" button, but here, for https://git.drupalcode.org/project/drupal/-/merge_requests/440, I do not.
@huzooka, can you please go to https://git.drupalcode.org/project/drupal/-/merge_requests/440/edit and change the target branch? 🙏
Comment #22
Wim LeersIMHO it makes no sense that drupal.org automatically changed the target version from
9.2.x-dev
to9.3.x-dev
in #12 but did not change the target branch of the MR. 😔But hey, okay, sticking to
9.2.x
then… rebasing again onto the latest9.2.x
instead! 🤞Comment #23
Wim LeersHere's a reroll of #10, now for
9.2.0-rc1
.Comment #24
huzookaRe #21: I see that the MR tells that it was created by me, but it was quiteone imho.
I'm afraid neither I have an Edit button.
Comment #25
quietone CreditAttribution: quietone as a volunteer commentedCame back to review. I have started to write a response several times and deleted it several times. I just don't know where to start. Trying again.
It is very frustrating for all of us that the rebase to 9.3.x failed. This will need to be on 9.3.x, not 9.2.0-rc1.
Not wanting to hold this up I applied that patch locally and then jumped to Gitlab to look at the unresolved issues. Looking at those and the applied patch I see the my comments, such as this, https://git.drupalcode.org/project/drupal/-/merge_requests/440#note_23224, haven't had a response yet.
I then read the patch.
This is kinda cryptic. I don't remember, are both 'default' and 'format_interval' Drupal 6 only? I don't know, maybe, 'The following are for Drupal 6 only.'?
I prefer the comment before the 'if' but there doesn't seem to be a coding standard for this. I will take it as a lesson in being flexible.
Part of me likes the removal of all this to code and another part likes seeing it in the yml. Overall, consistency wins and having D6 and D7 migrations and code the same, as much as possible, is preferred.
Let's expand this one too. 'The following formatters are Drupal 6 only.' or some such.
This is new to me. I have never seen a migrate_field_info_alter hook, nor can I find anything about it. Where to look?
That is all I can manage now.
Comment #26
Wim LeersI made a rebase mistake:
#3051252: Upgrade path for Multiupload Filefield Widget and Multiupload Imagefield Widget already added such a method :)
… and that also happens to explain the 124 failures. Probably all of them. Hopefully. 🤞
#5: Addressed all your feedback in #25 and on the MR 😊
#25.5 This is undocumented by Drupal core. See:
\Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager()
, which isclass MigrateFieldPluginManager extends MigratePluginManager implements MigrateFieldPluginManagerInterface {
$type
, which the constructor receives from the service definition incore/modules/migrate_drupal/migrate_drupal.services.yml
:#2683435: CCK does not exist in Drupal 7, rename Migrate's cckfield plugins to field plugins introduced it.
Comment #27
Wim LeersAaand #3213616: Map all Datetime module's field formatters from D6/D7 to D8/D9 just landed which forces the need for another rebase here. 7850074a is finally actually running tests 🥳
@quietone On the bright side: this can be easily rebased between
9.2.x
and9.3.x
— the only real problem here is the fact that Drupal.org's GitLab merge request refuses to let me test the same merge request against multiple branches. That is a huge regression compared to the patch-based workflow IMHO 😬Since we can't change the target branch … I propose to be pragmatic: let the target branch continue to be
9.2.x
, keep pushing commits there, and just upload a test explicitly for testing against9.3.x
😅 Did that here. This matches exactly what is in the merge request :)Comment #28
quietone CreditAttribution: quietone as a volunteer commented@Wim Leers, thank you for making a 9.3.x patch.
Everything in #25 has been address. And I have been given a lesson in a plugin hook, \Drupal\Core\Plugin\DefaultPluginManager::alterInfo. Thanks again Wim Leers.
Not sure about this. According to https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/modules/imag... the default widget is image_image, and a mapping for this widget is already provided in \Drupal\image\Plugin\migrate\field\d6\FileField.
Comment #29
Wim Leers#28: Very sharp observation! @huzooka, why did you add that?
Comment #30
huzookaRe #28:
That's a bit complicated, but isn't too difficult to explain:
hook_migrate_field_info_alter()
implementation replaces the inherited D6 plugin definitions' class with its own FileField migration plugin class, and there it overrides the mapping ofimagefield_widget
toimage_image
(see #25.5)1 . Fortunately, I noticed an error as I wrote this comment:
file
, so\Drupal\file\Plugin\migrate\field\d6\FileField::getFieldType()
should returnfile
.I'd completely remove it and replace with a
type_map
annotation (type_map: {"fielfield" => "file"})\Drupal\file\Plugin\migrate\field\d7\FileField::getFieldType()
shouldn't have to be modified, because if you don't declare a type_map, then it will automatically use the plugin ID even as source and as a destination field type.\Drupal\file\Plugin\migrate\field\d6\FileField::getFieldType()
– since core Image depends on file, this is the right way to properly migrate file/image fields.\Drupal\image\Plugin\migrate\field\d6\ImageField
extends this replacement class above, and it does not have anygetFieldType()
method override. So if its parent class already returns the right field type, then this plugin shoudn't be modified.\Drupal\image\Plugin\migrate\field\d7\ImageField
extendsFieldPluginBase
, and it addresses only d7image
fields, so it isn't affected.2. And an another suggestion: Don't we have to ensure (with a (new?) test) that these
map
keys remain empty (before any\Drupal\migrate_drupal\Plugin\MigrateFieldInterface
method gets called in\Drupal\migrate_drupal\Plugin\migrate\FieldMigration(::getProcess)
)?Needs work because of (1) 😢. I'm really sorry I missed it before (but I'm very happy that the review process revealed it 🧐).
Comment #31
quietone CreditAttribution: quietone as a volunteer commentedDespite the late hour I decided to read #30. I did and I do need to sleep on it. Even so, this feels like it is pushing the scope from a 'conversion' to 'conversion and improvements to the d6 field plugins'. If the latter is true then can we keep this just to conversion and move the improvements to a followup?
Cheers
Comment #32
huzooka@quiteone for me, it feels a lot safer to do these right now than removing the complicated parts. I think it is far better to do more here (and fix these kind of tiny bug) than the risk of adding regressions.
I will happily address these if we can agree :).
Comment #33
Wim Leers#32 is waiting for a response from @quietone, making that clearer 🤞
Comment #34
quietone CreditAttribution: quietone as a volunteer commentedComment #35
quietone CreditAttribution: quietone as a volunteer commentedOK. I think I have time and energy to look at this again.
Shouldn't this be 'The default formatter' instead of 'The date
formatter'?
These appear to be adding new functionality. I still think that it
should be in a separate issue. This method is also not tested or even
executed in the existing tests, d6\MigrateFieldWidgetSettingsTest.php
and d6\MigrateFieldFormatterSettingsTest.php or Upgrade6Test.
I saw a comment from Wim Leers above suggesting comments be added to explain
these empty maps and I agree.
I am able to run existing tests without this change. Why is it needed?
I still want to see the conversion of existing functionality separated out from the additional functionality and a separate one for the file migration (I think). If that were done I think it would be easier to find regressions, not harder. It would allow us to identify what needs a new test.
There is also a personal aspect, I want to see these changes committed and if this was split up it I would be encouraged to review the issues promptly.
Comment #36
quietone CreditAttribution: quietone as a volunteer commentedForgot I got assigned to this.
Comment #37
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commented#27 no more applies against 9.3.x and needs a reroll though, I guess.
Comment #38
kostyashupenkoComment #39
quietone CreditAttribution: quietone as a volunteer commented@kostyashupenko, can you provide an interdiff? There are instructions for creating an interdiff . If you think a diff is not needed, just add a comment stating why.
Comment #41
narendraRRerolled fix only patch for 9.3.x
Comment #42
nojj CreditAttribution: nojj as a volunteer commentedwhich path should I use for 9.3.3 ?
#39 oder #41
Comment #44
omkar.podey CreditAttribution: omkar.podey at Acquia commentedRerolled fix only patch for 9.4.x
Comment #45
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commented@quietone, I tried interdiffing #27 with #44 and #27 with #38 using patchutils like the documentation suggested here. But can't seem to create the interdiff. Is it even possible to create interdiffs between 2 patches that use different Versions of Drupal?
EDIT: Also tried it using
interdiff -iwbB
to ignore basically everything, still the hunks do not match...Comment #46
AnybodyJust tried to create the interdiff between #27 and #38:
interdiff 3204212-field-migration-widget-formatter-mapping-27.patch 3204212-38.patch > interdiff-27-38.txt
The result can be seen below, but as @kostyashupenko never replied what #38 is about and if it's just a reroll against 9.3.x (I think so!) or solving the comments from #35 (and I don't think it does!).
So I'd suggest to proceed with the MR (against 9.2.x see #27) using the review from #35.
@huzooka are you planning to work on this again here?
The fix-only patches can be rerolled against current Drupal Core versions by anyone who needs the fix NOW. :)
Comment #47
AnybodyAddressed #35.1 and #35.3. Sadly for the rest I'm not experienced enough here. :(
Comment #49
Wim LeersThis no longer applies to
9.5.x
. Will work on that unless somebody beats me to it 🤓Comment #50
AnybodyThank you @Wim Leers that would be a true christmas present to have this fixed. I'm honestly missing experience in the #35.1 and #35.3 parts as written above.
Comment #51
Wim LeersStraight reroll of #44 — just needed a small conflict resolution caused by #3112452: Fix indentation consistency in core's yaml files..
Comment #52
Wim LeersFix #44's
cspell
failures.Comment #53
Wim LeersReroll for
10.0.0
. Necessary due to #3290810: Remove updates added prior to 9.4.0 (9.4.4 for ckeditor) and add 9.4.0 database dumps.Comment #54
Anybody@Wim Leers: Do you have permission to change the target branch of the MR to 10.1.x? I sadly don't.
That would make the (interdiff) changes a lot more transparent.
As of #50 who might have the knowledge to fix #35.1 and #35.3 finally?
We're heavily relying on this patch plus #3202462: [PP-1] Provide option for contrib modules to map their D6 / D7 field formatter and widget plugin IDs to the equivalent D9 plugin ID. The situation is really messy :(
Drupal migrations are such a pain due to these issues. I'm sure we're losing a lot of people in this process. (No criticism, we're a community. And this is open source. Just saying.)
Comment #56
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedPatch #52 doesn't apply on 9.5.10. 9.5.7 works just fine.
Comment #57
slasher13re-roll Patch #52
Comment #58
benjifisherIt is too late for this issue to be fixed for D9, so I am re-rolling the patch from #53 for 11.x. The conflicts come from #3000717: Missing mapping for "nodereference_url" widget.
I have not done anything to fix the tests, but I am setting the status to NR in order to trigger a new test.
Comment #59
benjifisherIn #54, @Anybody pointed out that there are outstanding points from the review in #35. I am adding that to the issue summary (remaining tasks).
Comment #61
Wim LeersThis is still blocking #3202462: [PP-1] Provide option for contrib modules to map their D6 / D7 field formatter and widget plugin IDs to the equivalent D9 plugin ID and #3108302: [PP-2] Field formatter & widget settings: fall back to default if missing plugin.
Without the infrastructure added here + those 2 issues, it is IMPOSSIBLE for contrib modules providing field formatters and widgets to provide a D7 → D9/10/11 migration 😬
I guess most people just manually migrate those settings and hence this has never been a priority for migration system contributors?
I know that #35 requested this to be split up more. But it's already been split up in 3 parts.
https://www.drupal.org/project/acquia_migrate has been running with these patches for years now. And we've contributed many patches to contrib modules that build on top of these. Clearly many others are interested in it too 😊 I'm hoping somebody else can push the remaining pieces forward 🤞
#54: I don't either 😭 Only core committers can do that!
@quietone can you please change the target branch to
11.x
? 🙏#35:
FieldPluginBase
, in 2017. This is just fixing the existing migration in core.Comment #62
Anybody(#61)
Ping :)
Comment #63
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedPatch from #58 doesn't apply anymore to current 11.x. Here is the new reroll.
Comment #64
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedNot working much with patches... I can't seem to retest the latest patch with 11.x? Latest option is 10.1.x.