Problem/Motivation

Currently the banned IP-addresses can only be removed one by one in the UI: /admin/config/people/ban

It would be much better to be able to remove them in bulk.
Additionally, (or as simple first step) it would also be helpful to have a "Clear all" option like in dblog (/admin/reports/dblog/confirm)

The current workaround is to delete the record in the database.

Steps to reproduce

Proposed resolution

  • Provide checkboxes for each banned IP to unban in bulk, like for example flood_control does by using TableSelect
  • Add an "Unban all" or "Flush all" or something similar button to clear all entries at once

Remaining tasks

Update summary
Change record

User interface changes

Before


After


API changes

Data model changes

Release notes snippet

N/A

Issue fork drupal-3427545

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Issue fork ban-3427545

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Anybody created an issue. See original summary.

anybody’s picture

Title: Allow bulk unbanning / removal and clearing ip addresses » Allow bulk unbanning / removal and clearing ip addresses (Flush all)
Issue summary: View changes
anybody’s picture

Issue summary: View changes

LRWebks made their first commit to this issue’s fork.

lrwebks’s picture

Status: Active » Needs work
lrwebks’s picture

Assigned: Unassigned » lrwebks
lrwebks’s picture

Status: Needs work » Needs review
lrwebks’s picture

I'm currently still writing the appropriate tests for the new behaviors, but @Anybody could already take a look at what's implemented!

anybody’s picture

Thanks @LRWebks looks great! Just some textual changes.

anybody’s picture

Status: Needs review » Needs work
lrwebks’s picture

Status: Needs work » Needs review

Added the required test for the bulk unbanning and corrected all occurrences of "unblock" to "unban"! Unfortunately the test file seems to have been modified since we started with this issue - @Anybody, could you try to resolve this as I am not very experienced with resolving core merge conflicts...

anybody’s picture

Status: Needs review » Needs work

@LRWebks makes sense to learn it then :)

I think this is hopefully simple: GitLab reports:

Conflict: This file was modified in the source branch, but removed in the target branch. Ask someone with write access to resolve it.

for
core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
See https://git.drupalcode.org/project/drupal/-/merge_requests/9095/diffs#di...

So maybe you should first check that. Typically "Update fork" is often enough, but the thing above seems to cause the conflict.

Changes LGTM.

This is a good chance to understand how Git & forking works and how to update the issue fork to the target branch.

Safe hint: Often it's helpful to save the patch (Save target from "plain diff" link above)
So if things go wrong, you can easily restore the status by applying the patch using 3-way-merge.

anybody’s picture

anybody’s picture

@LRWebks: The learning: Before proceeding work on an (highly active) project (especially core) it makes sense to first update the fork (here in GitLab UI), then pull and then continue working. Then the risk is lower for things like this to happen.

lrwebks’s picture

Status: Needs work » Needs review

Well, everything should be in order now - I rebased everything and since the old test file was split into a Kernel and a Unit test, the UI test got its own Functional test class now.

lrwebks’s picture

The pipeline is currently failing, unfortunately, this seems to be due to the new tests established in #3468435: Convert IpAddressBlockingTest to a Unit and Kernel test and improve... My test is fine, what now?

anybody’s picture

Status: Needs review » Needs work

phpstan fails

anybody’s picture

anybody’s picture

@LRWebks no I was wrong and that was misleading. You need to update the tests, as you introduced a new parameter to the constructor!

That's why it fails.

lrwebks’s picture

Status: Needs work » Needs review

Okay, I've updated the BanAdminTest to work with our changes. Back to review!

smustgrave’s picture

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

Left some comments on MR.

Since we are changing UI text may need usability sign off also.

lrwebks’s picture

I've tried for a while now to figure out what is causing the test failures, and I must say that I'm really not sure. I have run the failed tests locally, and they work for me. The test failures also seem unrelated again. It could be because I updated the fork and the new commits are causing this - I'll try updating again and see if that changes anything.

lrwebks’s picture

Status: Needs work » Needs review

Well, that was really it! So what's left now is:

  • @smustgrave, please respond to my comment so that I can quickly fix the problem
  • Usability Review?
grevil’s picture

Status: Needs review » Needs work
StatusFileSize
new12.63 KB
new18.49 KB

I am not really a big fan of having the "Unban selected" button in the "actions" section:
screenshot

I think having the button under the table feels "more organically" and more similiar to other drupal lists:
screenshot2

Furthermore, it would be nice if the button only appears if any ips are selected (using the states api).

Edit: Talked with @Anybody about this internally and he thinks using states here might be confusing.

grevil’s picture

Great work @lrwebks! I added a few more comments, which should be resolved.

@smustgrave here you said, that changing "unblock" to "unban" might need a "usability sign off" should we instead just use "unblock" instead of "unban" everywhere else?

Instead of a mixture of "unban", "unblock" and "delete"?

grevil’s picture

Made a few more comments.

lrwebks’s picture

Status: Needs work » Needs review

The pipeline failure seems unrelated, which happened in this issue before already, so the best solution to that is to wait for another commit to 11.x that fixes the issue and then update the fork.
Until then, this issue can go back to review as all current issues have been resolved.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs screenshots

Gave another round of reviews.

To get this ready for usability tagging for screenshots to be added to the issue summary so they can easily see the change.

lrwebks’s picture

Status: Needs work » Needs review
grevil’s picture

Status: Needs review » Needs work

@lrwebks can you add screenshots like @smustgrave asked for?

lrwebks’s picture

Here is a screenshot of the new ban admin UI:

And here is the "Delete Multiple" confirmation form:

For easy viewing I have also added the screenshots to the issue summary.

grevil’s picture

Nice! Added 3 more comments!

lrwebks’s picture

Status: Needs work » Needs review
grevil’s picture

Status: Needs review » Needs work

Back to "Needs work" based on @anybody's last comment.

lrwebks’s picture

Status: Needs work » Needs review
grevil’s picture

Assigned: lrwebks » Unassigned
Status: Needs review » Reviewed & tested by the community

LGTM! Pipeline green! 😁👍

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new2.57 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

anybody’s picture

@LRWebks: The bot reports:

Running PHPStan on changed files.
------ -----------------------------------------------------------------------
Line src/Form/BanDeleteMultiple.php
------ -----------------------------------------------------------------------
45 Method Drupal\ban\Form\BanDeleteMultiple::create() has no return type
specified.
------ -----------------------------------------------------------------------

[ERROR] Found 1 error

Is that correct and can you fix it?

mrinalini9 made their first commit to this issue’s fork.

mrinalini9’s picture

Status: Needs work » Needs review

Hi,

I was getting below error while ran PHPStan on file (core/modules/ban/src/Form/BanDeleteMultiple.php) instead of the error mentioned on #39:

vendor/bin/phpstan analyse core/modules/ban/src/Form/BanDeleteMultiple.php
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ -----------------------------------------------------------------------------------
Line BanDeleteMultiple.php
------ -----------------------------------------------------------------------------------
46 Unsafe usage of new static().
💡 See: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
------ -----------------------------------------------------------------------------------

[ERROR] Found 1 error

I have fixed this error and have updated MR, please review it.

Thanks & Regards,
Mrinalini

anybody’s picture

Status: Needs review » Needs work

@mrinalini9 thanks, but the class needs to be final then, read https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static

mrinalini9’s picture

Status: Needs work » Needs review

Hi,

I have made the class final, please review it.

Thanks!

anybody’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots

Thanks, back to RTBC.
Screenshots were provided in #32, so I'm removing that tag.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new2.57 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mrinalini9’s picture

Status: Needs work » Needs review

Fixed PHPStan issues reported by bot in #45, please review it.

Thanks!

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs change record

Screenshots of the current UI isn't an actual section of the summary. Before/after screenshots should go under User interface changes to help the usability team.

Since that section seems to be current UI there appears to be no after in the summary.

Also taking for a CR for the change in workflow/new service.

Will still need usability sign off before RTBC.

lrwebks’s picture

grevil’s picture

@lrwebks can you create a CR (change record) as well, as @smustgrave suggested? There is a link in the sidebar, which leads you to the CR creation, or you can go there directly, through https://www.drupal.org/node/add/changenotice?field_project=3060&field_is...

lrwebks’s picture

Status: Needs work » Needs review

Added the CR! Now we are left with the Usability Signoff.

anybody’s picture

Issue tags: -Needs change record

Thanks @LRWebks! Needs usability review left now.

lrwebks’s picture

Status: Needs review » Needs work
quietone’s picture

Status: Needs work » Postponed

The Ban Module was approved for removal in #1570102: [Policy] Deprecate Ban module.

This remains Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3482198: [meta] Tasks to deprecate the Ban module and the removal work in #3488827: [meta] Tasks to remove Ban module.

Ban will be moved to a contributed project after the Drupal 12.x branch is open.

anybody’s picture

Project: Drupal core » Ban
Version: 11.x-dev » 1.0.x-dev
Component: ban.module » Code
Status: Postponed » Active

Moving this over to the Ban module. I'm unsure if we should finish this here or instead wait for a possible merge of the Ban and the Advban module (that already may have this functionality)?

anybody’s picture

Project: Ban » Drupal core
Version: 1.0.x-dev » 11.x-dev
Component: Code » ban.module
Status: Active » Postponed

Sorry for moving this over too early, my mistake -.-
Reverting #54.

We'll prepate separate MRs against core and the contrib ban module to be safe.

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.

mstrelan’s picture

Project: Drupal core » Ban
Version: main » 1.0.x-dev
Component: ban.module » Code
Status: Postponed » Needs work

This is good to move now

anybody’s picture

Version: 1.0.x-dev » 1.1.x-dev
Assigned: Unassigned » grevil
Issue tags: -Needs Review Queue Initiative, -Needs usability review

Let's also finish this one!

grevil changed the visibility of the branch 3427545-allow-bulk-unbanning to hidden.

grevil changed the visibility of the branch 11.x to hidden.

grevil’s picture

Assigned: grevil » Unassigned

Applied the core patch to the contrib module.

I'll test and finalize this once #2972332: Introduce the ability to use CIDR Notation to ban IP-Ranges is merged. Since there will be a few merge conflicts.

anybody’s picture

grevil’s picture

Assigned: Unassigned » grevil

Since #2972332: Introduce the ability to use CIDR Notation to ban IP-Ranges is postponed for now, I'll finish this now.

grevil’s picture

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

Did some final adjustments, should be good to go.

anybody’s picture

Status: Needs review » Needs work
Issue tags: +UX

Thank you all for the implementation and especially the tests! This LGTM, I just added two minor questions / phrasing suggestions.

Maybe @smustgrave and @mstrelan could check this for final RTBC and leave their feedback?

Very helpful UX addition, thanks! Let's get this finished.

grevil’s picture

Status: Needs work » Needs review
anybody’s picture

Copying my comment from the MR here for reference regarding logging:

We didn't receive further feedback, so I'd say let's keep it like this and add a @todo linking this issue.

The point why I think we shouldn't introduce that IP address logging is:
1. The string can become VERY long and unreadable
2. It might be a GDPR issue to log all these IPs in further logs... maybe forever.

Wasn't logged before either, so let's not do it for now. Maybe it could become a feature request to add a setting for that later.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Tests are present, manually testing also was fine, so RTBC! Thank you all!

  • grevil committed 53e41ed5 on 1.1.x
    feat: #3427545 Allow bulk unbanning / removal and clearing ip addresses...
grevil’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.