diff --git a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php index 5fbaa3fbf4d01425fde54977bf1119bf987f2477..790f32b5bcf1f30159f54df551c8ca521213267e 100644 --- a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php @@ -63,7 +63,9 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Con */ public function convert($value, $definition, $name, array $defaults) { $entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults); - + if (!$this->entityTypeManager->hasDefinition($entity_type_id)) { + return NULL; + } // If the entity type is dynamic, confirm it to be a config entity. Static // entity types will have performed this check in self::applies(). if (strpos($definition['type'], 'entity:{') === 0) { diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php index 8b64d11a43a0d05601def626738bc0f72b72572e..52d1c3b61cf7081264f7a0ef48100a3696425bc4 100644 --- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php @@ -53,6 +53,10 @@ public function testCommentInterface() { $comment = $this->postComment($this->node, $comment_text); $this->assertTrue($this->commentExists($comment), 'Comment found.'); + // Test that using an invalid entity-type does not raise an error. + $this->drupalGet('comment/reply/yeah-this-is-not-an-entity-type/' . $this->node->id() . '/comment/' . $comment->id()); + $this->assertSession()->statusCodeEquals(404); + // Test the comment field title is displayed when there's comments. $this->drupalGet($this->node->toUrl()); $this->assertSession()->responseMatches('@<h2[^>]*>Comments</h2>@');