Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Steps to reproduce:
- Install standard profile
- Create article content
- Add comment
- Edit comment type (
admin/structure/comment/manage/comment
) and change the comment target entity type to something other than content. - Visit article node again ... kaboom!
Fatal error: Call to a member function getSetting() on a non-object in /Volumes/devdisk/dev/sites/drupal8alt.dev/core/modules/comment/src/CommentViewBuilder.php on line 293
Proposed resolution
Prevent changing once field using comment type has been created?
Remaining tasks
Write patch.
User interface changes
Disable field if this can not be changed?
API changes
Not sure.
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff.txt | 617 bytes | swentel |
#8 | comment-type-entity-type-change-snafoo-2303521.8.patch | 2.95 KB | swentel |
#5 | comment-type-entity-type-change-snafoo-2303521.5.patch | 2.82 KB | larowlan |
#5 | interdiff.txt | 1.95 KB | larowlan |
#2 | comment-type-entity-type-change-snafoo-2303521.pass_.patch | 2.62 KB | larowlan |
Comments
Comment #1
larowlanYep should be removed if entity isn't new, patch coming
Comment #2
larowlanHoping for Red/Green
Comment #4
BerdirIs this really necessary?
The entity building should be intelligent enough to only update existing values, but I only know for sure that's true for content entities.
The first comment seems a bit strange, we're not really attempting to change it, as there's no way to do it (with the fix).
I think it should just say that we verify that it can not be changed and is a read-only information? The second comment is enough IMHO for both lines of code. Possibly add an assertion for the label?
Comment #5
larowlanFixes 4
Comment #6
BerdirThanks, no need to hold this up further.
Comment #7
alexpottDo we not need to tell the user that this can only be set when creating the comment type?
Comment #8
swentel CreditAttribution: swentel commentedSomething like this ?
Comment #9
larowlanThanks
Comment #10
webchickCommitted and pushed to 8.x. Thanks!