Problem/Motivation
In the same sense as in #2891932: Refactor D7 Field source plugin, the FieldInstance source plugin should returns all instance, as unmodified as possible, and also the field definition.
It should also be returning an array of arrays of all the instances that are using the same base field because we will this in #2842222: D7 Plain text fields incorrectly migrated to D8 as Text (formatted).
Since three other field source plugins are fetching the field_config_instance table, and since we will also need the array of instances for processing the widget and formatter, we should extend the refactored FieldInstance class in those, which are:
- FieldInstancePerFormDisplay
- FieldInstancePerViewMode
- ViewMode
Proposed resolution
Refactor FieldInstance source plugin by removing the extra processing and by adding the field definition and array of instances.
Refactor the three other classes by extending FieldInstance.
Remaining tasks
Write a patch, Review
User interface changes
None.
API changes
Some fields returned by the source plugins are changing to best mirror what's coming from the source.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | interdiff-2891935-22-25.txt | 916 bytes | maxocub |
| #25 | 2891935-25.patch | 48.42 KB | maxocub |
| #22 | interdiff-20-22.txt | 640 bytes | maxocub |
| #22 | 2891935-22.patch | 48.28 KB | maxocub |
| #20 | interdiff-18-20.txt | 1.56 KB | jofitz |
Comments
Comment #2
maxocub commentedHere's a first patch, and a patch including the one from #2891932: Refactor D7 Field source plugin for testing.
Comment #4
maxocub commentedFix the failing test and add the field_definition to the expected result for the FieldInstance source plugin test.
Comment #5
maxocub commentedNew approach without extending the Field source plugin.
Comment #7
maxocub commentedComment #8
phenaproximaSelf-assigning for review.
Comment #9
heddnAssigning to myself for review this week.
Comment #10
heddnI really like how this is shaping up. Some minor points noted.
This is a BC break that gets exposed to users of migrate_drupal. If someone starts migrating their site on 8.3, then in 2 months updates the site to 8.4, the field instance migrations are going to die a horrible death. We can either address this in a CR or keep a BC shim in place. Perhaps we can go with a CR since migrate_drupal is still experimental and the needed changes for the scenarios just mentioned are fairly minor.
Are we sure we need this? I don't see where we are pulling 'widget_type'.
Comment #11
maxocub commentedRe #10.2: This TextField plugin is used both for D6 & D7 (for now at least). In D6, the source plugin return a widget_type key, but in D7 it doesn't. The D7 fieldInstance source plugin has been addapted to reproduce what the D6 one was doing, but in the name of returning the source as unmodified as possible, I remove the processing of this key in the D7 source and I added this check.
Comment #12
maxocub commentedAlso, while working on #2842222: D7 Plain text fields incorrectly migrated to D8 as Text (formatted), I realized we would also need to return an array of all instances of the same base field with each instances.
So, in addition of the 'field_definition', we would also need 'instances' added to each row.
This is because we need to know if all instances are plain text or formatted text to know what type of widget & formatter to use.
Comment #13
heddnChatted about this in IRC and we are OK with breaking BC and the necessary updates for the field_instance yml file. But that means we need a CR.
Mark this @internal.
Comment #14
maxocub commentedAdded the @internal and the 'instances' array to each row as mentioned in #12.
Comment #15
heddnGoing to work on a draft CR. Patch in #14 is looking good.
@maxocub in IRC: FieldInstancePerFormDisplay.php FieldInstancePerViewMode.php ViewMode.php all should maybe extend FieldInstance where possible
Back to NW.
Comment #16
maxocub commentedHere's the refactoring of FieldInstancePerFormDisplay, FieldInstancePerViewMode & ViewMode, all extending FieldInstance.
This was needed for #2842222: D7 Plain text fields incorrectly migrated to D8 as Text (formatted), to have access to all field instances using the same base field while we are processing the widget and the formatter.
Comment #18
maxocub commentedFix the tests and update the IS.
Comment #19
maxocub commentedThe interdiff didn't completely uploaded with the last comment, so here it is.
Comment #20
jofitzI'm gonna be 'that guy' - here are a few coding standards corrections.
Comment #21
heddnGoing to review this.
Comment #22
maxocub commentedAuto-nitpicking: Forgot to add 'instances' to the FieldInstance fields().
Comment #24
heddnOne small question. Otherwise, this looks good to go. I also added a quick 8.5 test, just to make sure nothing fishing is going on here.
This seems odd. Can we add a comment why this is needed?
Comment #25
maxocub commentedRe: #24:
This snippet of code was previously in the FieldInstance source plugin, I moved it in the more logical FieldInstanceDefaults process plugin.
I added a comment to explain why it is needed.
Comment #26
heddnAll my concerns addressed. LGTM and unblock our critical.
Comment #27
maxocub commented@heddn: Thanks for the CR, I added some missing changes.
Comment #28
heddnUn assigning
Comment #29
xjmIn #2842222-107: D7 Plain text fields incorrectly migrated to D8 as Text (formatted), that critical issue was marked postponed on this issue. If this issue is a hard blocker, it needs to be critical itself.
Promoting this one to critical, at least for now so that is visible and can be evaluated.
Comment #30
heddnThis is a hard blocker. So bumping priority is a good suggestion.
Comment #31
maxocub commentedBumping to Critical as per #2842222-111: D7 Plain text fields incorrectly migrated to D8 as Text (formatted).
Comment #33
maxocub commentedSeems like an unrelated fail, back to RTBC.
Comment #34
catchCommitted/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!
Comment #37
maxocub commentedComment #38
maxocub commented