diff --git a/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php b/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php index f1a6d43..3707b3d 100644 --- a/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php +++ b/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\field; +use Drupal\Core\Entity\EntityInterface; use Drupal\system\Plugin\views\field\BulkForm; /** @@ -19,6 +20,19 @@ class CommentBulkForm extends BulkForm { /** * {@inheritdoc} */ + protected function calculateEntityBulkFormKey(EntityInterface $entity, $use_revision) { + return $entity->id(); + } + + protected function loadEntityFromBulkFormKey($id) { + return $this->entityManager + ->getStorage($this->getEntityType()) + ->load($id); + } + + /** + * {@inheritdoc} + */ protected function emptySelectedMessage() { return $this->t('Select one or more comments to perform the update on.'); } diff --git a/core/modules/comment/src/Tests/Views/CommentAdminTest.php b/core/modules/comment/src/Tests/Views/CommentAdminTest.php index c91bb29..6025117 100644 --- a/core/modules/comment/src/Tests/Views/CommentAdminTest.php +++ b/core/modules/comment/src/Tests/Views/CommentAdminTest.php @@ -69,7 +69,7 @@ function testApprovalAdminInterface() { $this->drupalLogin($this->adminUser); $edit = array(); $edit['action'] = 'comment_publish_action'; - $edit['comment_bulk_form[0]'] = $anonymous_comment4->language()->getId() . '-' . $anonymous_comment4->id() . '-'; + $edit['comment_bulk_form[0]'] = $anonymous_comment4->id(); $this->drupalPostForm('admin/content/comment/approval', $edit, t('Apply')); $this->assertText('Publish comment was applied to 1 item.', format_string('Operation "@operation" was performed on comment.', array('@operation' => 'publish'))); @@ -88,8 +88,8 @@ function testApprovalAdminInterface() { $this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), 'Two unapproved comments waiting for approval.'); $edit = array( "action" => 'comment_publish_action', - "comment_bulk_form[1]" => $comments[0]->language()->getId() . '-' . $comments[0]->id() . '-', - "comment_bulk_form[0]" => $comments[1]->language()->getId() . '-' . $comments[1]->id() . '-', + "comment_bulk_form[1]" => $comments[0]->id(), + "comment_bulk_form[0]" => $comments[1]->id(), ); $this->drupalPostForm(NULL, $edit, t('Apply')); $this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), 'All comments were approved.'); @@ -100,9 +100,9 @@ function testApprovalAdminInterface() { // Delete multiple comments in one operation. $edit = array( 'action' => 'comment_delete_action', - "comment_bulk_form[1]" => $comments[0]->language()->getId() . '-' . $comments[0]->id() . '-', - "comment_bulk_form[0]" => $comments[1]->language()->getId() . '-' . $comments[1]->id() . '-', - "comment_bulk_form[2]" => $anonymous_comment4->language()->getId() . '-' . $anonymous_comment4->id() . '-', + "comment_bulk_form[1]" => $comments[0]->id(), + "comment_bulk_form[0]" => $comments[1]->id(), + "comment_bulk_form[2]" => $anonymous_comment4->id(), ); $this->drupalPostForm(NULL, $edit, t('Apply')); $this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.'); diff --git a/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php index 5821274..0cae835 100644 --- a/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php +++ b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php @@ -57,6 +57,8 @@ public function testConstructor() { ->with('action') ->will($this->returnValue($entity_storage)); + $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); + $views_data = $this->getMockBuilder('Drupal\views\ViewsData') ->disableOriginalConstructor() ->getMock(); @@ -87,7 +89,7 @@ public function testConstructor() { $definition['title'] = ''; $options = array(); - $comment_bulk_form = new CommentBulkForm(array(), 'comment_bulk_form', $definition, $entity_manager); + $comment_bulk_form = new CommentBulkForm(array(), 'comment_bulk_form', $definition, $entity_manager, $language_manager); $comment_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $comment_bulk_form);