Problem/Motivation
Comes from #2422013: Integrity constraint violation - Column 'comment_status' cannot be null
Generating default Article nodes with devel_generate produces the following error:
Integrity constraint violation: Column 'comment_status' cannot be null
Looks like the issue is because CommentItem
is not overriding generateSampleValue()
.
Proposed resolution
Add generation of status
property that actually stored in field, see CommentItem::schema()
and CommentItem::propertyDefinition()
that mark only status as required.
Remaining tasks
- Write a patch
- Review
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#15 | 2422101-comment-generate-15.patch | 3.17 KB | andypost |
#15 | interdiff.txt | 849 bytes | andypost |
Comments
Comment #1
penyaskitoThis fixes the issue, but I don't think is the proper fix.
Comment #2
Manuel Garcia CreditAttribution: Manuel Garcia commentedJust confirming... with both this patch and the one on the devel_generate thread, devel_generate works again :)
Comment #3
willzyx CreditAttribution: willzyx commentedComment #4
clemens.tolboomThis needs a test like done in \Drupal\datetime\Tests\DateTimeItemTest. I checked for CommentItemTest.php but there is none.
Comment #5
pcambraLooking into this, the issue comes a little upstream, comments are not created the same way that the rest of the fields.
This will need some more work in terms of how to be able to pass the entities to generateValues without breaking the interface and also pool the author of the comment from the existing users.
Here's a patch in the good direction, I think
Comment #6
Manuel Garcia CreditAttribution: Manuel Garcia commentedContent seems to be generated fine (using patch #3 from devel_generate issue), but when I visit a node with comments, I see this fatal error:
Fatal error: Call to a member function label() on a non-object in /var/www/drupal8/core/modules/comment/src/Entity/Comment.php on line 402
Comment #7
andypostThis code is enough to make devel work (tested)
Probably needs to extend with other fields from
CommentItem::propertyDefinitions()
this is totally wrong
that's enough to make sure other properties of the field populated
any reason to save?
Comment #8
willzyx CreditAttribution: willzyx commented@Manuel Garcia
note patch #3 from devel_generate issue fix only devel_generate tests
@andypost
i agree with you #7 should enough to make devel work but probably we needs to extend generateSampleValue with other fields from
CommentItem::propertyDefinitions
.. and I think we still need test coverage forCommentItemTest
Comment #9
andypostSo here's a test and test+patch
Comment #10
andypostNo reason to extend because only status property is stored in field, others are populated on load
Comment #11
andypostoh, previous patches are wrong
Comment #13
willzyx CreditAttribution: willzyx commentedRTBC for me
Comment #14
clemens.tolboomThis assumes ordered values which might change in the future. Better use something inline with
Comment #15
andypost@clemens.tolboom Nice catch! Fixed
Comment #16
andypostComment #17
Fabianx CreditAttribution: Fabianx commentedRTBC, works great!
Major because generating content is crucial for proper benchmarking.
Comment #18
alexpottAre we going to address the other properties in a followup or in this issue? I would have though generating content with comments is crucial for proper benchmarking?
Comment #19
clemens.tolboomThis needs a summary update explaining what we do with
Comment #20
andypost@alexpott comment field have only one
status
property, other properties are populated in runtime and there's #2304939: Stop loading comment statistics into entity objectFixed summary.
Comment #21
alexpottCommitted 0972ecb and pushed to 8.0.x. Thanks!