Problem/Motivation
It's possible for comments to develop bad references: a reference to a parent comment, host entity or author that is not valid (e.g. deleted). This shouldn't ever happen in theory, but experience has shown that in practice due to bugs or data migrations it can (see e.g. #2906470: Orphan comments and entries in comment_entity_statistics after comment field instance has been deleted).
If a reference is invalid, this can lead to fatal errors when rendering comments.
For example, if a parent comment has somehow disappeared then the Drupal standard installation gives a "Fatal error: Call to a member function url() on null in /Volumes/SSD2/www/8/core/modules/rdf/rdf.module on line ..." when that comment gets loaded.
Proposed resolution
1) Create a Kernel test that creates a comment with invalid references and renders it.
2) Fix whatever needs fixing for the rendering to happen without error. These are checking for NULL returns from getParentComment in template_preprocess_comment. Checking for NULL returns from getCommentedEntity in CommentLazyBuilders::renderLinks, CommentViewBuilder::getBuildDefaults, and CommentViewBuilder::buildComponents. And finally checking that the user entity exists in Comment::getAuthorName.
Remaining tasks
* review
User interface changes
None.
API changes
None.
Data model changes
None.