diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 1beb1a1..86aa0a0 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -440,11 +440,16 @@ function rdf_preprocess_comment(&$variables) { // Adds RDFa markup for the relation between the comment and its author. $author_mapping = $mapping->getPreparedFieldMapping('uid'); if (!empty($author_mapping)) { - $author_attributes = array('rel' => $author_mapping['properties']); - // Wraps the author variable and the submitted variable which are both - // available in comment.html.twig. - $variables['author'] = SafeMarkup::set('' . $variables['author'] . ''); - $variables['submitted'] = SafeMarkup::set('' . $variables['submitted'] . ''); + // Wraps the 'author' and 'submitted' variables which are both available in + // comment.html.twig. + foreach (['author', 'submitted'] as $variable) { + $variables[$variable] = [ + '#type' => 'markup', + '#tag' => 'span', + '#attributes' => ['rel' => $author_mapping['properties']], + '#value' => $variables[$variable] + ]; + } } // Adds RDFa markup for the date of the comment. $created_mapping = $mapping->getPreparedFieldMapping('created'); @@ -457,11 +462,15 @@ function rdf_preprocess_comment(&$variables) { '#theme' => 'rdf_metadata', '#metadata' => array($date_attributes), ); - $created_metadata_markup = drupal_render($rdf_metadata); // Appends the markup to the created variable and the submitted variable // which are both available in comment.html.twig. - $variables['created'] = SafeMarkup::set(SafeMarkup::escape($variables['created']) . $created_metadata_markup); - $variables['submitted'] = SafeMarkup::set($variables['submitted'] . $created_metadata_markup); + foreach (['created', 'submitted'] as $variable) { + $variables[$variable] = [ + // Ensure the original variable is represented as a render array. + !is_array($variables[$variable]) ? ['#markup' => $variables[$variable]] : $variables[$variable], + $rdf_metadata, + ]; + } } $title_mapping = $mapping->getPreparedFieldMapping('subject'); if (!empty($title_mapping)) {