diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index b40660c..bdd36f8 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -275,21 +275,20 @@ public function validateForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { $operation = $form_state->getValue('operation'); $cids = $form_state->getValue('comments'); + /** @var \Drupal\comment\CommentInterface[] $comments */ + $comments = $this->commentStorage->loadMultiple($cids); if ($operation != 'delete') { - foreach ($cids as $cid) { + foreach ($comments as $comment) { // Delete operation handled in // \Drupal\comment\Form\ConfirmDeleteMultiple // @see \Drupal\comment\Controller\AdminController::adminPage(). if ($operation == 'unpublish') { - $comment = $this->commentStorage->load($cid); $comment->setPublished(FALSE); - $comment->save(); } elseif ($operation == 'publish') { - $comment = $this->commentStorage->load($cid); $comment->setPublished(TRUE); - $comment->save(); } + $comment->save(); } drupal_set_message($this->t('The update has been performed.')); $form_state->setRedirect('comment.admin'); @@ -298,8 +297,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { else { $this->tempStoreFactory ->get('comment_multiple_delete_confirm') - ->set($this->currentUser()->id(), - $this->commentStorage->loadMultiple($cids)); + ->set($this->currentUser()->id(), $comments); $form_state->setRedirect('comment.multiple_delete_confirm'); } }