diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index b3934b9d9c7ef59718242edee65c2e2c1202a9a2..8833651a3dca526a05a626a318e59c4e5651db03 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -118,8 +118,9 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#title' => $this->t('Comments per page'), '#default_value' => $settings['per_page'], '#required' => TRUE, - '#min' => 1, + '#min' => 0, '#max' => 1000, + '#description' => $this->t('Enter 0 to show all comments.'), ]; $element['anonymous'] = [ '#type' => 'select', diff --git a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php index 23565102837b67b2f5b63eb444ce9d2b30f6478a..ae1038cb21b0f6eede4aee8760211aeca8981968 100644 --- a/core/modules/comment/tests/src/Functional/CommentFieldsTest.php +++ b/core/modules/comment/tests/src/Functional/CommentFieldsTest.php @@ -184,6 +184,15 @@ public function testCommentFieldCreate() { $this->submitForm($edit, 'Save field settings'); // We shouldn't get an error message. $this->assertSession()->pageTextNotContains('The submitted value in the Comment type element is not allowed.'); + + // Try to save the comment field with "Comments per page" + // setting value as zero. + $edit = [ + 'settings[per_page]' => 0, + ]; + $this->drupalGet('admin/config/people/accounts/fields/user.user.field_user_comment'); + $this->submitForm($edit, 'Save settings'); + $this->assertSession()->statusMessageContains('Saved User comment configuration.', 'status'); } /** diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php index 4039e2b36d55f2b44a43de61dc3376db8745aeaa..2f25713e0ea567bcb5902fce44c6901a9b9f8336 100644 --- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php @@ -38,6 +38,14 @@ public function testCommentPaging() { $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.'); + // Set "Comments per page" as zero and verify that all comments are appearing + // on the page. + $this->setCommentsPerPage(0); + $this->drupalGet('node/' . $node->id()); + $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page.'); + $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page.'); + $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page.'); + // Set comments to one per page so that we are able to test paging without // needing to insert large numbers of comments. $this->setCommentsPerPage(1); @@ -92,6 +100,10 @@ public function testCommentPaging() { $this->setCommentsPerPage(0); $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertFalse($this->commentExists($reply2, TRUE), 'Threaded mode works correctly when comments per page is 0.'); + // Test that all main comments are appearing in the threaded mode. + $this->assertTrue($this->commentExists($comments[0]), 'Comment 1 appears on page.'); + $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page.'); + $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page.'); $this->drupalLogout(); }