Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / comment.module
index ee26510729e32f1a515eda19c476e050a3a6dde9..bb203bf64419e05c7420a58a6ceeda36b43b84e9 100644 (file)
@@ -31,6 +31,8 @@ use Drupal\user\RoleInterface;
  *
  * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
  *   Use \Drupal\comment\CommentInterface::ANONYMOUS_MAYNOT_CONTACT instead.
+ *
+ * @see https://www.drupal.org/node/2831620
  */
 const COMMENT_ANONYMOUS_MAYNOT_CONTACT = 0;
 
@@ -39,6 +41,8 @@ const COMMENT_ANONYMOUS_MAYNOT_CONTACT = 0;
  *
  * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
  *   Use \Drupal\comment\CommentInterface::ANONYMOUS_MAY_CONTACT instead.
+ *
+ * @see https://www.drupal.org/node/2831620
  */
 const COMMENT_ANONYMOUS_MAY_CONTACT = 1;
 
@@ -47,6 +51,8 @@ const COMMENT_ANONYMOUS_MAY_CONTACT = 1;
  *
  * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
  *   Use \Drupal\comment\CommentInterface::ANONYMOUS_MUST_CONTACT instead.
+ *
+ * @see https://www.drupal.org/node/2831620
  */
 const COMMENT_ANONYMOUS_MUST_CONTACT = 2;
 
@@ -331,18 +337,6 @@ function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInte
   }
 }
 
-/**
- * Implements hook_form_FORM_ID_alter() for 'field_storage_config_edit_form'.
- */
-function comment_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state) {
-  if ($form_state->getFormObject()->getEntity()->getType() == 'comment') {
-    // We only support posting one comment at the time so it doesn't make sense
-    // to let the site builder choose anything else.
-    $form['cardinality_container']['cardinality']['#default_value'] = 1;
-    $form['cardinality_container']['#access'] = FALSE;
-  }
-}
-
 /**
  * Implements hook_entity_storage_load().
  *
@@ -353,8 +347,7 @@ function comment_entity_storage_load($entities, $entity_type) {
   if (!\Drupal::entityManager()->getDefinition($entity_type)->entityClassImplements(FieldableEntityInterface::class)) {
     return;
   }
-  // @todo Investigate in https://www.drupal.org/node/2527866 why we need that.
-  if (!\Drupal::hasService('comment.manager') || !\Drupal::service('comment.manager')->getFields($entity_type)) {
+  if (!\Drupal::service('comment.manager')->getFields($entity_type)) {
     // Do not query database when entity has no comment fields.
     return;
   }
@@ -640,7 +633,7 @@ function template_preprocess_comment(&$variables) {
     '#theme' => 'username',
     '#account' => $account,
   ];
-  $variables['author'] = drupal_render($username);
+  $variables['author'] = \Drupal::service('renderer')->render($username);
   $variables['author_id'] = $comment->getOwnerId();
   $variables['new_indicator_timestamp'] = $comment->getChangedTime();
   $variables['created'] = format_date($comment->getCreatedTime());
@@ -686,7 +679,7 @@ function template_preprocess_comment(&$variables) {
       '#theme' => 'username',
       '#account' => $account_parent,
     ];
-    $variables['parent_author'] = drupal_render($username);
+    $variables['parent_author'] = \Drupal::service('renderer')->render($username);
     $variables['parent_created'] = format_date($comment_parent->getCreatedTime());
     // Avoid calling format_date() twice on the same timestamp.
     if ($comment_parent->getChangedTime() == $comment_parent->getCreatedTime()) {