diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 3816fc4e1435..fc833b8efd2c 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -56,12 +56,14 @@ class CommentManager implements CommentManagerInterface { /** * {@inheritdoc} */ - public function getFields($entity_type = NULL) { - $map = $this->getAllFields(); - if (!isset($map[$entity_type])) { + public function getFields($entity_type) { + $info = $this->entityManager->getDefinition($entity_type); + if (!is_subclass_of($info['class'], '\Drupal\Core\Entity\ContentEntityInterface')) { return array(); } - return $map[$entity_type]; + + $map = $this->getAllFields(); + return isset($map[$entity_type]) ? $map[$entity_type] : array(); } /** diff --git a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php index 84a3589e9f62..b1747f2ab8c8 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php @@ -27,7 +27,7 @@ interface CommentManagerInterface { * Utility function to return an array of comment fields. * * @param string $entity_type - * The entity type to return fields which are attached on. + * The content entity type to which the comment fields are attached. * * @return array * An array of comment field map definitions, keyed by field name. Each @@ -38,7 +38,7 @@ interface CommentManagerInterface { * * @see field_info_field_map() */ - public function getFields($entity_type = NULL); + public function getFields($entity_type); /** * Utility function to return all comment fields.