Steps to reproduce:
- Go to /admin/structure/types/manage/article/display.
Configure a ds layout with fields for 'default' view mode. - Go to /admin/structure/types/manage/article/display/teaser.
Choose a ds layout, and put one of the fields into the content region. - Go to /devel/php, and execute
dpm(ds_get_field_settings('node', 'article', 'teaser'));
.
Result: The fields configured for 'teaser' view mode show up. - Go again to /admin/structure/types/manage/article/display/teaser.
Remove all fields from all regions. - Go to /devel/php, execute
dpm(ds_get_field_settings('node', 'article', 'teaser'));
.
Expected result: Empty array.
Actual result: The fields configured for 'default' view mode.
Use case:
In my case, a custom ds layout that does some magic by itself, and does not need any fields.
As a more general case: A ds layout that is filled with some fields, but none of them is a "ds field".
Problem:
Some fields are processed even though they are disabled.
In my case, one of them - a "related products" view - caused an infinite loop.
Technical explanation:
ds_field_ui_fields_save()
deletes the old entry in the ds_field_settings
table, and only creates a new entry if the fields are not empty.
ds_get_field_settings()
falls back to the 'default' view mode, if it does not find an entry in the ds_field_settings
table.
ds_field_attach_view_alter()
calls ds_get_field_settings($entity_type, $bundle, $view_mode)
, and then processes all the fields.
Possible solutions
In ds_field_ui_fields_save()
, save an entry with empty array in the ds_field_settings
table, if no fields are enabled.
or
In ds_get_field_settings()
, do NOT fall back to 'default' if there are layout settings for this view mode.
Comment | File | Size | Author |
---|---|---|---|
#7 | ds-2653034-7-ds_get_field_settings.patch | 1.79 KB | donquixote |
#5 | ds-2653034-5-ds_field_ui_fields_save.patch | 718 bytes | donquixote |
Comments
Comment #2
donquixote CreditAttribution: donquixote as a volunteer commentedComment #3
donquixote CreditAttribution: donquixote as a volunteer commentedSorry, I had forgotten the older issue, #2216661: infinite recursion with extra fields.
Still, I think this new issue has a more focused title description.
Comment #4
donquixote CreditAttribution: donquixote as a volunteer commentedComment #5
donquixote CreditAttribution: donquixote as a volunteer commentedComment #6
donquixote CreditAttribution: donquixote as a volunteer commentedComment #7
donquixote CreditAttribution: donquixote as a volunteer commentedHere is an alternative solution.
From #2216661: infinite recursion with extra fields