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
https://git.drupalcode.org/project/multiple_selects/-/blob/8.x-1.x/src/P... uses multiple_options_select
as the widget plugin ID.
But https://git.drupalcode.org/project/multiple_selects/-/blob/7.x-1.x/multi... uses multiple_selects
This means that migrations from D7 to D8|9 will not automatically pick up this migration.
Steps to reproduce
Proposed resolution
Alter the field configuration migration to do this automatically. #3051252: Upgrade path for Multiupload Filefield Widget and Multiupload Imagefield Widget can serve as an example.
Remaining tasks
Add a migration state file
Manual testing
Review
Commit
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#15 | 3188284-15.patch | 1023 bytes | Wim Leers |
#14 | 3188284-14.patch | 490.46 KB | quietone |
#14 | interdiff-8-14.txt | 29.02 KB | quietone |
#8 | 3188284-8.patch | 465.81 KB | Wim Leers |
#8 | interdiff.txt | 693 bytes | Wim Leers |
Comments
Comment #2
quietone CreditAttribution: quietone as a volunteer commentedAnd here is a patch.
Comment #3
quietone CreditAttribution: quietone as a volunteer commentedRename filed plugin file and fix coding standards. Not testing this patch because the tests are not running with run-tests.sh
FATAL Drupal\Tests\multiple_select\Kernel\Migrate\MigrateFieldTest: test runner returned a non-zero error code (2).
Comment #4
quietone CreditAttribution: quietone as a volunteer commentedThe migration tests now pass locally now with run-tests.sh. I also discovered that I was working in a module with the name multiple_select not multiple_selects. History shows I did
ddev composer require drupal/multiple_select:1.x-dev
which does exist but is not this module. What a nuisance to have two similarly named modules. Anyway, all updated now.Comment #5
quietone CreditAttribution: quietone as a volunteer commentedAnd I was working on D 9.2.x, so ran the tests with that. And I checked the test log, the tests are running. So all good here.
Comment #6
quietone CreditAttribution: quietone as a volunteer commentedOh, I think this should be tested with real world data.
Comment #7
quietone CreditAttribution: quietone as a volunteer commentedAlso, this needs a migration state file.
Comment #8
Wim LeersI tested this manually, on a real-world site. This does not work at all? 😅
Why only these two types? It supports much more!
Huh, this Field Widget Type is not even provided by the
multiple_selects
module?\Drupal\migrate\Plugin\migrate\destination\ComponentEntityDisplayBase::import()
is still calling it with unmodified raw values.I have a
field_course
node_reference
field. This is itsfield_config_instance
data:Why isn't this just modifying
process.widget_type_mapped[0].map
ind7_field_instance_widget_settings
? Wouldn't that solve it more accurately and with far less code?Basically, the alter hook equivalent of
… and by stepping through this with a debugger, I ended up with this, which does work for me too:
Comment #9
Wim LeersJust discussed with @phenaproxima.
He sort of reached the same conclusion. He wrote:
Wouldn't that make this 100x easier to support?
Comment #10
quietone CreditAttribution: quietone as a volunteer commented#8 - I only skimmed this and am not surprised by the comments. Migrating the widgets is hard.
#9 - Good idea to talk to phenaproxima! Yes, I agree that would be better. But let's try it locally first just to be sure.
Comment #11
Wim Leers👍
Comment #12
quietone CreditAttribution: quietone as a volunteer commentedTook a while to find this issue again. I found a core issue #3033522: Add methods to customize field to MigrateFieldInterface that adds functionality for FieldPluginBase, unfortunately, there isn't a alterFieldWidgetMigration. Once I get that rerolled, which is taking a long time, and back into shape it will be time to consider adding an alterFieldWidgetMigration.
Comment #13
Wim LeersThanks for that super helpful update! 🤩🙏
Comment #14
quietone CreditAttribution: quietone as a volunteer commentedNow that I've dabbled in the field migration again I am once frustrated that 'type' can mean so many things.
Whatever I was thinking in #10 I am no longer sure. It is already possible to alter the options/type migration for the widget as well as create a custom method to get the widget type (getFieldWidgetType) is that not enough? Or is the problem that the fixture doesn't have real world data? It is probably a good idea to add the fields that failed from the real world site to this fixture.
This patch adds getFieldWidgetType to the Multiple Select migratefield plugin. Maybe that will help with real world data? This also adds two more fields to the fixture, a list_float and an entityreference, both using the multiple_selects widget. Add to complete the range of tests there are now Functional tests.
Comment #15
Wim LeersPer #3202462-2: [PP-1] Provide option for contrib modules to map their D6 / D7 field formatter and widget plugin IDs to the equivalent D9 plugin ID, if #3204212: Convert remaining widget and formatter type migrations to MigrateField plugins and #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 were to land, then all we'd need is this:
… and we would not be putting the burden of writing complex test coverage on the shoulders of every single field formatter/widget contrib module maintainer. Which is good, because it increases the likelihood that they'll actually work on providing a migration path!
Comment #16
Wim Leers@huzooka should be credited for #15 btw 🤓