Needs review
Project:
Multiple Selects
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
14 Dec 2020 at 14:58 UTC
Updated:
15 Apr 2021 at 12:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
quietone commentedAnd here is a patch.
Comment #3
quietone 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 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-devwhich does exist but is not this module. What a nuisance to have two similarly named modules. Anyway, all updated now.Comment #5
quietone 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 commentedOh, I think this should be tested with real world data.
Comment #7
quietone 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_selectsmodule?\Drupal\migrate\Plugin\migrate\destination\ComponentEntityDisplayBase::import()is still calling it with unmodified raw values.I have a
field_coursenode_referencefield. This is itsfield_config_instancedata:Why isn't this just modifying
process.widget_type_mapped[0].mapind7_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 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 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 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 🤓