diff --git a/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php b/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php index 260eba2..07c6d54 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php +++ b/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Form; +use Drupal\comment\CommentInterface; use Drupal\comment\CommentStorageControllerInterface; use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; @@ -142,7 +143,7 @@ public function buildForm(array $form, array &$form_state, $type = 'new') { ); // Load the comments that need to be displayed. - $status = ($type == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED; + $status = ($type == 'approval') ? CommentInterface::NOT_PUBLISHED : CommentInterface::PUBLISHED; $header = array( 'subject' => array( 'data' => $this->t('Subject'), @@ -269,7 +270,7 @@ public function validateForm(array &$form, array &$form_state) { $form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0)); // We can't execute any 'Update options' if no comments were selected. if (count($form_state['values']['comments']) == 0) { - form_set_error('', $this->t('Select one or more comments to perform the update on.')); + $this->setFormError('', $form_state, $this->t('Select one or more comments to perform the update on.')); } } @@ -285,12 +286,12 @@ public function submitForm(array &$form, array &$form_state) { // see \Drupal\comment\Controller\AdminController::adminPage(). if ($operation == 'unpublish') { $comment = $this->commentStorage->load($cid); - $comment->status->value = COMMENT_NOT_PUBLISHED; + $comment->status->value = CommentInterface::NOT_PUBLISHED; $comment->save(); } elseif ($operation == 'publish') { $comment = $this->commentStorage->load($cid); - $comment->status->value = COMMENT_PUBLISHED; + $comment->status->value = CommentInterface::PUBLISHED; $comment->save(); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php index a44b5c9..e631da2 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php @@ -93,6 +93,12 @@ function testApprovalAdminInterface() { $this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.'); $this->drupalPostForm(NULL, $edit, t('Delete comments')); $this->assertText(t('No comments available.'), 'All comments were deleted.'); + // Test message when no comments selected. + $edit = array( + 'operation' => 'delete', + ); + $this->drupalPostForm(NULL, $edit, t('Update')); + $this->assertText(t('Select one or more comments to perform the update on.')); } /**