Problem/Motivation

When you have to moderate many spam comments the typical workflow is as follows:

  • Go to admin/content/comment/approval
  • Mass select comments (e.g. all on the page)
  • Select Delete the selected comments in the dropdown
  • Click Update
  • On the confirmation page flag them e.g. as spam and finally click on Delete comments button to complete the action

You'll now get redirected to admin/content/comment. From an usability standpoint, this is very prone to errors as you might not have realized you're back to the approved comments pane and can then repeat the operation to delete legit comments this time instead of continuing to delete spam comments.

Proposed resolution

Change the unapproved comments deletion confirmation page to redirect to admin/content/comment/approval as long as we have unapproved comments.

Remaining tasks

Write a patch.

User interface changes

Confirmation page after mass deleting of unapproved comments now redirects to admin/content/comment/approval if the number of unapproved comments is superior to 0

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anavarre created an issue. See original summary.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gnosis’s picture

I will work on this.

My intention is to make the redirect back to /admin/content/comment/approval in all cases, as this will display the "nothing here" copy on the "unapproved comments" list. The ensures the moderator that he/she has finished the queue.

gnosis’s picture

Issue tags: +#nola2016
eporama’s picture

Gnosis, now that nola2016 is in the books, did we make any progress on this? I don't want to step on toes if that's the case.

gnosis’s picture

Yes, I did solve the issue on Friday, but had to run to catch plane. I'm back at the office now and should be able to post a patch today.

gnosis’s picture

Status: Active » Needs review
FileSize
526 bytes

This issue actually occurs not just in the redirects, but also in the Cancel buttons. It happens whether you are on the "Published Comments" tab (comment.admin) or on the "Unapproved Comments" tab (comment.admin_approval), because these share the same code. That is, \Drupal\comment\Form\ConfirmDeleteMultiple is used for the bulk op either way.

Currently, the method getCancelUrl() is hard-coded to return route comment.admin, which is the "Published Comments" tab. The confirm submit handler completes by redirecting to getCancelUrl(). The result is that regardless of what tab you're on, and whether you complete the action or not, you're always going to end up back at comment.admin.

The solution in this patch is to change getCancelUrl() to return whichever route the user was already on rather than hard-code it. I have tested this and it solves the problem for both the Cancel buttons and the submit redirect: the user ends up back where they were instead of forced to the default task/tab.

Status: Needs review » Needs work

The last submitted patch, 7: mass_comment_moderation-2680133-7.patch, failed testing.

gnosis’s picture

Hm. Looks like my solution fails because there is no HTTP request in the test context. It seems like it should be possible to insert a condition to check for it and return the previous hard-coded route if no request exists, but I don't know if that's acceptable.

I'm not sure how this usability issue could be resolved without some way to know which task/tab the user was on when they initiated the bulk op.

Oddly, when I run the phpunit group comment on my local, with this patch, all tests pass. Not sure what the difference is there. But it does make some sense that no request object would be present in the test env.

eporama’s picture

Status: Needs work » Needs review
FileSize
506 bytes
548 bytes

I went through the same process and originally wanted to simply remove the call to setRedirectUrl() completely within submitForm, but that led to a lot of &d=admin/comment/approval querystrings.

I think that it would work to invoke routeMatch() instead of request().

I have attached a new patch and interdiff for testing.

anavarre’s picture

If I'm not mistaken, I think we should use dependency injection if at all possible in class files.

gnosis’s picture

Patch in #10 seems perfect to me. Tested in the GUI and it works as expected; it does the same thing as my original patch, but in a better way that passes automated tests.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.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.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now 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.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.

Tagging for needs tests.

Will also tend to agree with #11 that dependency injection is best practice.

Moving back to NW for those 2 things.

Version: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.