Setting this to major because it is a common situation that totally aborts the migration process.
To recreate the problem, create several view modes in the source database. Set some fields to be hidden in some of the view modes. Then attempt a migration. When you get to the migration process for d6_field_formatter_settings, the migration will stop with a message like:
Failed to lookup array (
0 => 'text',
1 => 'hidden',
) in the static map.
I think hidden fields should be treated like excluded fields and just skipped when processing view modes. I'm attaching a patch that would do that. It allowed me to get through the migration without errors when I had hidden fields. And in the resulting D8 site all the fields looked right, hidden in the view modes they should be hidden on.
This was one cause of problems noted in https://www.drupal.org/node/2361401.
| Comment | File | Size | Author |
|---|---|---|---|
| #46 | fields_hidden_in_some-2498291-46.patch | 5.41 KB | jofitz |
| #46 | interdiff-42-46.txt | 3.08 KB | jofitz |
| #42 | fields_hidden_in_some-2498291-42.patch | 4.94 KB | jofitz |
| #39 | fields_hidden_in_some-2498291-39.patch | 4.95 KB | quietone |
| #39 | fields_hidden_in_some-2498291-39-test-only.patch | 2.93 KB | quietone |
Comments
Comment #1
karens commentedHere's the solution I came up with.
Comment #2
karens commentedProbably not major to Drupal core as a whole, but critical for the migration system.
Comment #3
benjy commentedThe fix makes sense if the fields default to hidden in D8 which is what the IS says.
Can we add a test for this?
Comment #4
karens commentedI'm not sure how the D8 test system works, so this might take a while. If someone wants to add a test to this that would be great :)
Comment #5
karens commentedComment #6
benjy commentedTagging as novice, if someone wants to work on this feel free to ping me in #drupal-migrate for some assistance.
Comment #7
th3m0d commentedI'm going to jump in on this one. So this fix is good to go if all the fields are hidden @benjy said. What does IS stand for? Trying to determine if you're asking for a conditional check inside the function or a unit test to review the patch.
EDIT: After further reading I understand what context you guys are using the word 'test' in. I should have this done in the next day or so.
Comment #8
ultimikeComment #9
mikeryan@th3m0d: Did you have a chance to work on a test for this?
Thanks.
Comment #10
neclimdulNot sure if this is the right fix but here is a re-roll around The Great 2015 Migration Migration
Comment #11
neclimdulanother reroll
Comment #12
sdstyles commentedComment #18
neclimdulThat's weird... I wonder how we got stuck on 8.1.x
Comment #20
quietone commentedI can't reproduce the error. But then, the views I made aren't migrated at all. No error messages on screen nor could I find any in log files.
Do you mean select 'exclude from display' when you say "Set some fields to be hidden in some of the view modes"?
Comment #21
karens commentedThis has nothing to do with views or 'exclude from display'. I'm talking about when you set up the display for a content type and on some view modes, like the 'teaser' view mode, you have some fields hidden. Exclude from display means they are still rendered, hidden means they are not rendered at all.
I just tried the latest bleeding edge branch and this is still a problem. Everything migrates fine until it gets to the formatter migration, where it fails if there are hidden fields, and then at least some of the migrations afterwards all fail. I end up with all my content types and fields set up but no data in them.
Comment #22
neclimdulI'll make it a priority to provide test date.
Comment #23
quietone commented@KarenS, thx for the explanation. I thought I had it wrong.
Comment #24
mikeryanThe fix looks good, but we do need to add this scenario to the D6 dump and test it.
Is it an issue in D7 as well?
Comment #25
kari.kaariainen commentedThis happens in D7: "Missing formatter: The 'text_hidden' formatter used in 1 view modes for the field_myfield field is not available, these displays will be reset to the default formatter."
Comment #26
svendecabooterI can't reproduce this in D6 nor D7.
When I set certain fields as hidden in some view modes (full, teaser), I get no errors upon migration to Drupal 8.
On my Drupal 8 install, all fields that have been marked hidden in D6 / D7, are still in the "hidden" region, and thus not rendered on node view.
Could someone who still has this problem elaborate on the steps to reproduce this?
Comment #27
kari.kaariainen commentedOK, I now realize that this issue is about hidden fields. I was talking about excluded fields (the excluded column with a checkbox). Sorry.
Comment #28
svendecabooterAFAIK Drupal 7 doesn't have that excluded checkbox?
I tested the checkbox in D6, and the result is the same as with a hidden field: in D8 the field gets moved into the Hidden region of the view mode.
So not sure if this issue is still relevant at this point.
Comment #29
kari.kaariainen commentedA field that was excluded in D6 doesn't get moved into the Hidden region in D7. Maybe I should add a new issue for that.
Comment #30
quietone commentedComment #32
mikeryanCan't seem to "add test" on the patch, so forcing a retest (which I'm betting will demonstrate a reroll is needed...)
Comment #33
mikeryanGuess it's too old - re-uploading (committers - no credit for me on this!).
Comment #34
heddnLooks like we need to add some tests. While that *could* be easy, writing tests isn't generally super simple. Removing the novice tag.
Comment #36
phenaproximaThis definitely needs tests. It shouldn't actually be too tricky -- just load the resulting D8 entity_view_display entity and ensure that the hidden field (or "component" in D8-ese) does not exist in the view display.
Comment #37
mitrpaka commentedTesting if needs re-roll. Some offset found. Patch updated.
Comment #39
quietone commentedChanged an existing field to hidden and added a test for that in MigrateFieldFomatterSettings.
Comment #41
jofitz@quietone Is it possible for
$field_row['display_settings'][$view_mode]['format']to be unset? That's the only issue I can see. Otherwise this is ready for RTBC (after it has been re-rolled).Also removed the "Needs tests" tag because #39 includes them.
Comment #42
jofitzRe-rolled.
Comment #43
phenaproximaLooks great. Nice and simple, and there is test coverage. I just have two tiny concerns:
I'd prefer to use assertNull here.
This code is repeated in FieldInstancePerViewMode. If one of these classes extends the other, can this logic be a helper method, with a doc comment to explain exactly what it does? Also, a nitpick: there is an extra space before the final &&.
Comment #44
jofitz@phenaproxima can you give more details on how you see the helper method working, please? I've got plenty of ideas, but they all seem to have flaws. e.g. FieldInstancePerViewMode could extend ViewMode, but then we are adding calculateDependencies() to FieldInstancePerViewMode. Another idea was to transfer many of ViewMode's methods to ViewModeBase, but I suspect that is not a good idea even though these are the only two classes that extend that.
Comment #45
phenaproximaOh -- I only meant that we should have a helper method if one of the classes already extends the other. If that is not the case, then I'm OK with duplicating the code, as long as there is a comment that is a) duplicated in both places; b) explaining what the if statement is doing; and c) has a @see that mentions the other place where the same if check exists.
Comment #46
jofitzComment #47
phenaproximaExcellent! Full stream ahead...
Comment #48
joelpittetMy other issue seems to conflict with this one where I went with
!empty()@Jo Fitzgerald could you review and feel free to close mine if the change isn't needed with what you've changed here.#2854314: D6 FieldInstancePerViewMode has a default viewmode with no settings
Comment #49
jofitz@joelpittet I've taken a look at your ticket, but I don't think there is any conflict with this one. Have a look at my patch(es) for more details on my thoughts: https://www.drupal.org/node/2854314#comment-11994882
Comment #50
joelpittetThey were just failing to apply with composer patches between each other, didn't diff the diffs just wanted to show they were touching the same lines with empty check
Comment #51
alexpottCommitted and pushed acc5c66 to 8.4.x and 3610a36 to 8.3.x. Thanks!