Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
migration system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Feb 2015 at 13:19 UTC
Updated:
2 Apr 2015 at 10:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
chx commentedThis is not a migrate thing; it's a migrate_drupal thing.
Comment #2
benjy commentedOK, first version of the patch, leaving as postponed because it depends on #2422227: Add setProcessOfProperty to Migration entity
Few notes:
* I added methods like isFieldMigration(), isFieldWigetMigration to MigrationStorage so we could easily add the D7 migrations when they come about. We could also fire a drupal_alter here to allow other modules to add migrations in case D5 migrations ever come in contrib. Or, they could override the storage controller.
* Core isn't using the new plugin type yet. If we're happy on the general approach i'll convert a few field types. It does work though, I tested with a contrib port of iFrame: https://www.drupal.org/sandbox/benjy/2422307
Comment #3
benjy commentedAdded a migration id to plugin method map instead of the individual methods.
Comment #5
benjy commentedFurther clean-up, not looked at the fails yet.
Comment #7
benjy commentedNasty little problem where the source plugin's config gets cached because the storage controller calls getSourcePlugin() and then if anything else tries to set the source config after the migration has been loaded it is never used.
The attached patch shows the problem but I'm not convinced it's the correct approach?
Another approach could be to add a setSourceConfig() method onto the migration and then invalidate the source plugin cache from there? I don't much like $entity->set('source', $source) anyway.
Comment #9
benjy commentedThe problem was trying to access fieldData() for the migration with the load plugin attached when we only want that for the bundle migration.
We could have just checked for that migration like below but I decided to checkout against $migration->load
Comment #10
chx commentedWouldn't
!$migration->get('load')suffice? Also, I am surprised that superflous processing causes tests to break. Of course we shouldn't do superflous processing so this needs to stay but isn't processing a no-op when applied to migrations we do not need/want to process?Comment #11
benjy commentedYes, that would also work.
It isn't the actual processing that causes the error. It's an undefined index CckFieldValues::fieldData() when $this->configuration['bundle'] is not set. Eg for the top level d6_cck_field_values migration.
Comment #12
benjy commentedSwitched to using getDerivativeId() instead of checking the load plugin array.
Added a setSourceConfig method which is only really used in tests and invalidated the sourcePlugin cache.
Comment #13
benjy commentedThis is nearly ready but postponed on: #2422227: Add setProcessOfProperty to Migration entity
Just need to convert some core field types to use this.
Comment #14
benjy commentedOK, this is unblocked now. Re-rolled against HEAD.
Comment #15
chx commentedDo we perhaps want to override set() instead? I think we want to.
Comment #16
benjy commentedYes I like that, I think it's better than requiring another public method on the entity.
Comment #17
benjy commentedComment #18
amateescu commentedHere's a small review, nothing alarming stands out :)
Afaik, we have to include the leading slash everywhere we use a class or interface name as a string.
'successfully migration' sounds a bit weird :)
We can save the use of
/** @var ... */by using\Drupal\migrate\Entity\Migration[]instead of array in the docblock.Looks like we can move these at the top of the method to save some calls in the foreach.
Are we missing a d6_field_instance here?
How about renaming everything to use 'formatter' instead of 'display'?
Comment #19
amateescu commentedAlso, related to the last point (#18.6), it seems that we're missing a
getFieldWidgetMap()method :)Comment #20
benjy commentedComment #21
amateescu commentedSo, I looked at d6_field_instance_widget_settings and that seems to hardcode the 1:1 mapping for *known widgets*, but isn't it possible, at least theoretically, that a contrib module provided two widgets in D6 and combined them into a single one (with more options) in D8?
Comment #22
benjy commentedSure, in that use you'd just add two entries to this same map, same as we've done for datetime_default
I added getFieldFormatterMap() to try give a slightly nicer DX. It allows contrib authors to skip implementing processFieldFormatter() and simply allows them return an array from getFieldFormatterMap() so the parent can handle updating the process array.
processFieldWidget() also has a default implementation in CckFieldPluginBase that sets a sane default based on your module name.
Nothing stops contrib modules doing what they want in processFieldWidget() and processFieldFormatter() and in that case they could ignore the return value from getFieldFormatterMap() altogether.
Maybe i've just confused things by adding getFieldFormatterMap(), we could change how that works?
Comment #23
benjy commentedOK, discussed this on IRC and we've now added a getFieldWidgetMap() to be consistent. I should also point out the lack of tests here, we'll be using the API in core for the link field etc which will give us implicit coverage, created a follow-up #2448501: Use the migrate cckfield plugin type for the link field
Comment #24
amateescu commentedAwesome, looks good to me now :)
Comment #25
alexpottNot used.
Missing docblocks for $field_name and $data
Comment #26
benjy commentedFixed.
Comment #27
chx commentedAlex's concerns are addressed.
Comment #28
alexpottRe #23 I think the lack of explicit test coverage might come back to bite us but maybe when #2448501: Use the migrate cckfield plugin type for the link field lands it will be more obvious how to add explicit coverage.
Committed 04a17f8 and pushed to 8.0.x. Thanks!