Closed (fixed)
Project:
Field Group
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2020 at 13:15 UTC
Updated:
30 May 2021 at 15:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
huzookaComment #3
wim leersThis was introduced in #2611904: Add migrate support for D6 fieldgroup.
🤔
This was introduced in #2611904: Add migrate support for D6 fieldgroup with barely any review. I'm not sure I understand yet why we're changing this though, because
\Drupal\Core\Entity\Entity\EntityViewModeis not the same as\Drupal\Core\Entity\Entity\EntityViewDisplay.And
d7_field_formatter_settingswould indeed have migrated/createdEntityViewDisplayconfig entities, which is wherefield_groupstores its data.So why exactly was this wrong?
👍
Right, this was downright wrong: returning the values of the affected entity view display even if it was not saved, because that destination config entity was not new.
This would've led to incorrect migration statistics. It would've led to weird behavior.
So: good changes, but AFAICT we've changed the migration dependencies into something incorrect. I feel I'm missing something? 🤓
Comment #4
huzookaRe #3:
I know that
\Drupal\Core\Entity\Entity\EntityViewModeis not the same as\Drupal\Core\Entity\Entity\EntityViewDisplay. But there are no (what I know) standalone migration that creates entity form or entity view display entities.Let's assume that the source Drupal instance has an article node with several fields (including a text field with field name
custom_text) which are grouped by field group, even on its form display, and even on its "default" and "teaser" view modes. How are this node type's required configurations migrated?field_storage_config) that are used by this node type (and by other node types, taxonomy terms or users etc) can be migrated very early, because they only depend on the entity type (in this case, this isnode).field_config), you have to migrate node types, because field configurations require a field storage (migrated in step #1 above), the target entity type (node), and the target bundle (article).The default entity form – and entity view displays are created by Drupal core when a specific bundle is created. So right after you've the node types migrated, you will also have
core.entity_form_display.node.article.defaultandcore.entity_view_display.node.article.defaultbesidesnode.type.article.field_config) can be migrated.field_configentities (migrated byd7_field_instance). In Drupal 7 core, you can't had multiple forms for a node type, that's why there isn't ad7_form_modesmigration.teaserview mode is also migrated. That's why core'sd7_field_formatter_settingsdepends on thed7_view_modesmigrations. This is because entity view displays require a target view mode, and obviously it should be present before the formatter migration is executed.So let's execute
d7_view_modesas well. This migration will create the view modecore.entity_view_mode.node.teaserview mode, and since it maps the view modedefaulttofull, it will also create acore_entity_view_mode.node.fullview mode for nodes.After that we did the steps above, we have the common base for the pre-existing Field Group migration path and for the "fixed" path I propose here.
Field formatter migrations have a special destination plugin
component_entity_view_display. This plugin loads the appropriate entity_view_display entity from the entity display repository; adds the processed field formatter settings to this display entity (or hides the actual component if it should be hidden), and saves it.At the very first field formatter settings row for the teaser, the loaded entity_view_display will be a new entity: this teaser view display configuration will be created at this point. Every further "
field formatter settings row for teaser" row will only modify this view display entity.But as you can see in this patch (that's why I removed
d7_field_instanceandd7_field_formatter_settingsfrom the kernel test), the field group settings can be migrated without thed7_field_formatter_settings. The only reason why it was necessary before this change was that the destination plugin checked the existence of the target entity view display entity. If we remove that, the only difference is that the "teaser" view display might be created by Field Group's destination plugin.Long story short: I'm not saying that the current migration is wrong, I just say that we have unnecessary dependencies (that's why I evaluated this issue as a "task". And I insist that this is true 🙃.
Comment #5
wim leersWow, thanks for this superb write-up! The detail is really helpful 🙏
It all makes perfect sense now, and should also help the
field_groupmaintainer understand why this patch makes sense 👍🥳Comment #7
nils.destoop commentedThx for the clear explanation. I committed the changes to dev.