diff -u b/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module --- b/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -308,8 +308,8 @@ } // Adds RDFa markup annotating the number of comments a node has. - $comment_count_mapping = $mapping->getPreparedFieldMapping('comment_count'); - if (\Drupal::moduleHandler()->moduleExists('comment')) { + if (\Drupal::moduleHandler()->moduleExists('comment') && \Drupal::currentUser()->hasPermission('access comments')) { + $comment_count_mapping = $mapping->getPreparedFieldMapping('comment_count'); if (!empty($comment_count_mapping['properties'])) { $fields = array_keys(\Drupal::service('comment.manager')->getFields('node')); $definitions = array_keys($variables['node']->getPropertyDefinitions()); only in patch2: unchanged: --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php @@ -125,9 +125,6 @@ public function testNumberOfCommentsRdfaMarkup() { 'datatype' => 'http://www.w3.org/2001/XMLSchema#integer', ); $this->assertTrue($graph->hasProperty($this->node_uri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).'); - // Makes sure we don't generate the wrong statement for number of comments. - $node_comments_uri = url('node/' . $this->node->id(), array('fragment' => 'comments', 'absolute' => TRUE)); - $this->assertFalse($graph->hasProperty($node_comments_uri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view mode (sioc:num_replies).'); // Tests number of comments in full node view, expected value is the same. $parser = new \EasyRdf_Parser_Rdfa();