Updated: Comment #14
Problem/Motivation
- comment_field_instance_create() contains logic to ensure that the default value of comment fields at least contains entries for each of the sub-values of a comment field, many of which are calculated (ie not present in comment_field_schema()). The logic incorrectly sets the value without respecting any existing default values the calling code may have set.
- Also it creates a body field on entity create, but should only do so on insert - which causes sync issues.
- Finally, there is some code referencing #731724: Convert comment settings into a field to make them work with CMI and non-node entities in field_purge_batch() that can be removed.
Proposed resolution
- Don't blindly set the default value, instead check for its presence first and only append the missing values..
- Don't create the body field in hook_field_instance_create, use hook_field_instance_insert instead.
- Remove chunk from field_purge_batch().
Remaining tasks
Reviews
User interface changes
None
API changes
None
Original report by @chx
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | comment-default-2172123.14.patch | 3.1 KB | larowlan |
| #14 | interdiff.txt | 1.7 KB | larowlan |
| comment_instance_default_clobbered.patch | 952 bytes | chx |
Comments
Comment #1
larowlanComment #2
larowlanshould be red/green
Comment #5
chx commentedComment #7
larowlan2: comment-default-2172123.pass_.patch queued for re-testing.
Comment #8
benjy commentedLooks good.
Comment #9
andypostcomment field cardinality is 1. so first line is useless
Comment #10
andypostthe fix, still rtbc
Comment #12
alexpottcomment_field_instance_create()also causes issues for syncing configuration and properly removing comment fields (currently excluded fromfield_purge_batch())This blocks #1808248: Add a separate module install/uninstall step to the config import process
Comment #13
larowlanUpdated issue summary/title
Working on this
Comment #14
larowlanHave at it bot.
Comment #15
larowlanComment #16
larowlanComment #17
andypostNot sure we still need hook create implementation because it was a workaround for fields created via Field UI that does not set default values. Suppose now Entity field api should set this defaults
Comment #18
chx commentedSo what's up with this critical now?
Comment #19
larowlan#17 default stuff is #2175017: FieldDefinition::create() doesn't populate default 'settings' for the field type
Comment #20
tim.plunkettThis was RTBC before, and @larowlan linked to the defaults issue.
The code looks good to me!
Comment #21
berdirThe referenced issue is only about FieldDefinition, meaning base fields *and* it's about settings, this is about the default value. Not related.
Comment #22
webchickThis looks straight-forward to me, but shooting it over to alexpott since he can better evaluate whether the fixes here unblock that other issue.
Comment #23
alexpottCommitted 854c866 and pushed to 8.x. Thanks!