Problem/Motivation

I am doing bulk updates for comments list with pagination.
I have a view to display list of unpublished comments with pagination.
I am displaying 10 comments and operation is to publish the comments.
Suppose there are 12 unpublished comments.
I am on page 2 and select all comments(2 on second page) to publish. Once the operation is performed, it stays on page 2 with message, "No comments found".
In actual, there are 10 comments present on page 1.
In this case, it should be redirected to page 1 but it is staying on page 2.

Drupal version : 8.9.14
PHP Version: 7.4.15

Steps to reproduce

Steps to Reproduce the Issue:
1. Install Drupal
2. log in as an admin
3. Go to "admin/structure/views/view/content"
4. And update the "items per page" to 4 from the Pager option.
5. Now create 10+ dummy content.
6. Go to the "/admin/content" page.
7. Go to last page of the content list.
8. Select all the content and delete them.
9. Verify the page number. The page number is updating to 2, but no content is displayed, while we have content on that page.
(This is the issue that we fix in this ticket).

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

mahesh.umarane created an issue. See original summary.

nishantghetiya’s picture

Hello @mahesh.umarane

Please attach view to display a list of unpublished comments with pagination on the issue description and provide some screenshots if possible.

mahesh.umarane’s picture

StatusFileSize
new45.25 KB
new20.35 KB

Thanks for the reply.

Its almost same as the core views of 'comments' i.e./admin/content/comment/approval
I also have attached the screens here, PFA.

mahesh.umarane’s picture

Priority: Normal » Major
richa_porwal’s picture

Assigned: Unassigned » richa_porwal
StatusFileSize
new1.39 KB

Hi Team,

I have created patch for the above problem motivation. Need review.

richa_porwal’s picture

Assigned: richa_porwal » Unassigned
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: 3215465-comment-bulk-operation.patch, failed testing. View results

meenakshi_j’s picture

Status: Needs work » Needs review
StatusFileSize
new6.74 KB
new6.13 KB

Fixed the fails of #5

ambuj_gupta’s picture

Assigned: Unassigned » ambuj_gupta
ambuj_gupta’s picture

Assigned: ambuj_gupta » Unassigned
Status: Needs review » Needs work
StatusFileSize
new139.02 KB

Steps to Reproduce the Issue:
1. Install Drupal 8.9.x
2. log in as an admin
3. Go to "admin/structure/views/view/content"
4. And update the "items per page" to 4 from the Pager option.
5. Now create 10+ dummy content.
6. Go to the "/admin/content" page.
7. Go to page 3 of the content list.
8. Select all the content and delete them.
8. Verify the page number. The page number is updating to 2 and no content is coming on it. While on that page we have content. (This is the issue that we fix in this ticket).

Testing Results:
I am not able to apply the patch. I tried manually as well but the patch not applied successfully.

dhirendra.mishra’s picture

StatusFileSize
new6.81 KB

I have manually added the changes by looking at #8. Now this patch should work

dhirendra.mishra’s picture

Status: Needs work » Needs review
ganesh_kumar’s picture

Hi dhirendra.mishra

This patch getting failed during upgrade of drupal 8 to latest release drupal 9 #3215465-11.patch. and getting the below error refer failed patch one while during update the composer.

Could you please update the patch of supporting the D9 as well to sort out this issue.

Failed Patch
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2021-07-14/3215465-11.patch

avpaderno’s picture

Version: 8.9.x-dev » 9.2.x-dev
Issue tags: -comment bulk operation

Drupal 8.9.x is now open only to security issues.

ganesh_kumar’s picture

StatusFileSize
new7.22 KB

Hi apaderno,

I have created the patch of latest version of Drupal core 9.2.5 and verified this patch and fuctionality working fine as expected.
Kindly check the patch of #13 comment - New Patch : 3215465-13.patch. Please verify the same.

gauravvvv’s picture

StatusFileSize
new7.09 KB
new735 bytes

Fixed custom command failed, added interdiff for same.

vikashsoni’s picture

Applied patch #16 applied successfully and looks good for me

Thanks for the page ------

Steps to Reproduce the Issue:
1. Install Drupal 9.2.x-dev
2. log in as an admin
3. Go to "admin/structure/views/view/content"
4. And update the "items per page" to 5 from the Pager option.
5. Now create some approx 15 dummy content.
6. Go to the "/admin/content" page.
7. Go to last page of content list
8. Select all the content and delete them.
9. Verify the page number. The page number is updating to 2 and no content is coming on it.
10 . Now apply the patch and rebuild the cache u will and check it you will get expected result

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

borisson_’s picture

This change looks to be a fix for a really annoying bug, so that is great. I don't like that we have a lot of changes in the tests, but it looks like that is because we were explicitly testing the presence of this bug? That sounds like a very weird thing it the design of those tests.

I'm not sure if need a change notice, but I would love if it if we could update the issue summary with the steps in #17

Manibharathi E R’s picture

StatusFileSize
new198.16 KB
new360.41 KB

Patch #16 Applied successfully on Drupal 9.4.x.

Before Patch:
Before-Patch

After Patch:
After-patch

gaurav-mathur’s picture

StatusFileSize
new49.02 KB
new72.13 KB

Applied patch #16 succesfully and working fine on drupal 9.4.x, refer to the screenshot.
Thank you

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

Status: Needs review » Needs work

Looks like this still needs an issue summary update.

  1. +++ b/core/modules/media_library/tests/src/FunctionalJavascript/WidgetViewsTest.php
    @@ -83,7 +83,7 @@ public function testWidgetViews() {
    -    $this->assertCount(1, $this->getCheckboxes());
    +    $this->assertCount(24, $this->getCheckboxes());
    

    I'm thrown by this quite big change to the test expectation. What's happening here??

  2. +++ b/core/modules/views/src/Plugin/views/query/Sql.php
    @@ -1515,7 +1515,25 @@ public function execute(ViewExecutable $view) {
    +          $total_pages = floor($total_rows / $view->pager->options['items_per_page']);
    

    Use getItemsPerPage().

  3. +++ b/core/modules/views/src/Plugin/views/query/Sql.php
    @@ -1515,7 +1515,25 @@ public function execute(ViewExecutable $view) {
    +          if (!empty($this->offset)) {
    +            if ($this->offset >= $total_rows) {
    +              $last_offset = $total_pages * $view->pager->options['items_per_page'];
    +              if ($last_offset == $total_rows) {
    +                $last_offset = $view->total_rows - $view->pager->options['items_per_page'];
    

    I'd like comments here to explain what we're calculating.

  4. +++ b/core/modules/views/src/Plugin/views/query/Sql.php
    @@ -1515,7 +1515,25 @@ public function execute(ViewExecutable $view) {
    +              // It never should be negative integer, causes sql syntax error.
    

    This feels a bit hacky.

    Is there a way of doing the calculation without having to force it to be positive at the end?

dhinakaran’s picture

StatusFileSize
new7.24 KB

Rerolled the patch for 9.5.x vesion

_utsavsharma’s picture

StatusFileSize
new7.22 KB

Patch for 9.5.x.

_utsavsharma’s picture

Status: Needs work » Needs review
borisson_’s picture

Status: Needs review » Needs work

Tests fail in latest patch + we need to figure out why the test expectations have change so much. Back to needs work.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

johnv’s picture

Title: Comment Bulk Operation issue with pagination » Pager pagination breaks when deleting content on Comment Bulk Operation
Issue summary: View changes

The problem is not only for this view, but for every view.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.