Problem/Motivation
When a rate widget has "Use a vote deadline" enabled, RateHooks::entityView() ends with:
$this->entityDisplayRepository->getFormDisplay($entity_type, $entity_bundle)->setComponent($field_name)->save();This runs on every render of an entity with the widget, not only when field_rate_vote_deadline is created. Since #3314312
the call passes no options. With no weight, EntityDisplayBase::setComponent() sets the weight to the highest weight in the display + 1. So on every uncached view:
- the deadline field moves to the bottom of the form display, and if it is already last, its weight goes up by one each time
- any widget settings for the field are reset to the defaults
- the form display config entity is saved during a page request
On sites that manage configuration in code, this shows up as config drift in core.entity_form_display.* after normal page views, and the next config import reverts it.
Steps to reproduce
- Create a rate widget for a node bundle with "Use a vote deadline" enabled.
- View a node of that bundle once, so the field is created.
- Export configuration.
- Clear caches and view the node again.
drush config:statuslistscore.entity_form_display.node.BUNDLE.defaultas Different; thefield_rate_vote_deadlineweight has changed.
Proposed resolution
Add the field to the form display only when the field config is created, inside the existing if (empty(FieldConfig::loadByName(...))) block. Existing sites keep whatever form display
settings they have. Patch attached.
Remaining tasks
- Review the patch.
- Add test coverage.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | rate-deadline-form-display-saved-on-every-view-3631013.patch | 953 bytes | ugolek |
Comments
Comment #2
ugolek commentedPatch moves the form display setComponent()->save() into the field creation block, so it runs once instead of on every view.
Comment #3
ugolek commented