Hello,

I am testing this module and I have nothing appearing in the report because I use Redis (https://www.drupal.org/project/redis) to handle the Flood service.

And so I don't have the flood table in the database and as this module make direct database queries there is no result.

I will try to make a patch.

CommentFileSizeAuthor
#94 flood_control-external-storage-2928007-94.patch38.44 KBgpz
#88 flood_control-external-storage-2928007-87.patch38.42 KBchist
#86 flood_control-external-storage-2928007-86.patch38.42 KBalexrayu
#85 flood_control-external-storage-2928007-85.patch38.42 KBalexrayu
#83 flood_control-external-storage-2928007-83.patch38.33 KBsergeimalyshev
#81 interdiff_80-81.txt4.56 KBelc
#81 flood_control-external-storage-2928007-81.patch37.12 KBelc
#80 flood_control-external-storage-2928007-80.patch37.08 KBelc
#78 flood_control-external-storage-for-flood-db-2928007-78.patch28.07 KBelc
#75 flood_control_2.3.3_d10.patch30.44 KBwill_frank
#70 flood_control-support_external_flood-2928007-70.patch26.69 KBpjovanovic
#69 flood_control_2.3.2_d10.patch26.27 KBwill_frank
#62 flood_control-support_external_flood-2928007-62.patch33.21 KBsergeimalyshev
#61 flood_control-support_external_flood-2928007-61.patch32.96 KBsergeimalyshev
#59 flood_control_2.3.2.patch26.25 KBwill_frank
#54 flood_control-support_external_flood-2928007-54.patch24.4 KBlisastreeter
#53 flood_control-support_external_flood-2928007-53.patch30.69 KBlisastreeter
#52 flood_control-support_external_flood-2928007-52.patch27.11 KBvanilla-bear
#48 flood_control-support_external_flood-2928007-48.patch24.44 KBlisastreeter
#45 flood_control-support_external_flood-2928007-45.patch25.28 KBmrdalesmith
#38 2928007-38.patch23.84 KBcatch
#36 support-external-flood-2928007-36.patch23.14 KBhmdnawaz
#26 flood_control-2928007-26.patch19.96 KBcatch
#26 2928007-25-26-interdiff.txt4.67 KBcatch
#25 flood_control-2928007-25.patch18.91 KBcatch
#25 2928007-interdiff-24-25.txt9.61 KBcatch
#24 flood_control-2928007-24.patch14.9 KBcatch
#23 flood_control-2928007-23.patch12.43 KBcatch
#22 flood_control-2928007-22.patch12.43 KBcatch
#19 2928007-19-support-redis-backend.patch13.34 KBandrewbelcher
#17 2928007-17-support-redis-backend.patch12.99 KBandrewbelcher
#8 interdiff-2928007-7-8.txt719 bytesgrimreaper
#8 flood_unblock-support_external-2928007-8.patch9.6 KBgrimreaper
#7 interdiff-2928007-4-7.txt6.15 KBgrimreaper
#7 flood_unblock-support_external-2928007-7.patch9.59 KBgrimreaper
#4 flood_unblock-support_external-2928007-4.patch7.66 KBgrimreaper
#4 redis-flood_unblock_external_flood-2928007-4.patch2.47 KBgrimreaper
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

Grimreaper created an issue. See original summary.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Active » Postponed

After looking more at the code, it appears that the module is already using the "flood" service. The flood service is used where it can be used.

Maybe it can also be used in the flood_unblock/src/FloodUnblockManager.php->flood_unblock_clear_event method.

But the problem is in the visualization of the registered flood because the core/lib/Drupal/Core/Flood/FloodInterface.php does not have the methods for that.

So the methods get_blocked_ip_entries and get_blocked_user_entries of the service FloodUnblockManager.php are required to do database queries.

I think only a feature request on Drupal core with the flood interface modified (and the native flood service) modified can solve this issue generically.

grimreaper’s picture

grimreaper’s picture

Status: Postponed » Needs review
StatusFileSize
new2.47 KB
new7.66 KB

Hello,

Here are two patches that are in the status of POC.

One for Flood unblock and the other one for Redis.

It also require the following code in the site services.yml file, to test with either the Redis Flood service or the new VisualizableDatabase one:

services:
  # Replaces the default flood backend with a redis implementation.
  flood:
    class: Drupal\Core\Flood\FloodInterface
    factory: ['@redis.flood.factory', get]

#  flood:
#    class: Drupal\flood_unblock\Flood\VisualizableDatabaseBackend
#    arguments: ['@database', '@request_stack']
#    tags:
#      - { name: backend_overridable }

As it is a POC, I have not modified the Predis version of the flood service, As it is almost the same as the Phpredis one, the change will be done later when the resolution will be validated.

The other thing these patches do not and maybe it will be a requirement, it is to dynamically replace the Database flood Backend by the Database visualize one if the core one is used. I plan to use a code similar to http://cgit.drupalcode.org/s3fs/tree/src/S3fsServiceProvider.php?h=8.x-3...

In Redis, I would require the help of a maintainer to understand how to alter properly the services with factory pattern.

There is a TODO for the flood_unblock_clear_event method of the FloodUnblockManager. I am waiting for feedbacks before searching for this one.

Thanks for the review.

berdir’s picture

+++ b/src/Flood/PhpRedis.php
@@ -10,7 +10,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
  * Defines the database flood backend. This is the default Drupal backend.
  */
-class PhpRedis implements FloodInterface {
+class PhpRedis implements VisualizableFloodInterface {
 
   use RedisPrefixTrait;
 
@@ -92,4 +92,49 @@ class PhpRedis implements FloodInterface {

you need to upload the redis patch to the redis issue queue.

The problem with this approach is that we can not add a hard dependency on flood_unblock but that's what you are doing with this. Instead, it would need to be a subclass of PhpRedis that lives somewhere, and you can optionally use that by overriding a service/factory/setting.

I'd also be open to adding a module exists check in the factory class to pick that class automatically or a service provider alter.

grimreaper’s picture

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

Thank you very much @Berdir for your reply.

Totally agree that there can't be hard dependency to flood unblock on redis. The previous patches are just at a POC state.

Working on this.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.59 KB
new6.15 KB

And here the new patch for flood unblock.

I will uplaod the Redis one in the redis issue.

Thanks for the review.

grimreaper’s picture

Small improvement. Using static constant.

fabianderijk’s picture

Assigned: Unassigned » fabianderijk

I will try to test this patch ASAP. Did you test this patch with a non-redis install as well? Does everything still work?

grimreaper’s picture

Hello,

Thanks for your reply.

I have tested the patch with the native database backend. But it require to override the flood service with this new one from the patch.

+++ b/flood_unblock.services.yml
@@ -1,4 +1,8 @@
+  flood_unblock.flood:
+    class: Drupal\flood_unblock\Flood\VisualizableDatabaseBackend
+    arguments: ['@database', '@request_stack']

You can make the override by adding the following lines in the services.yml file of your site:

  flood:
    class: Drupal\flood_unblock\Flood\VisualizableDatabaseBackend
    arguments: ['@database', '@request_stack']
    tags:
      - { name: backend_overridable }

Maybe a next step for this issue would be to have a service provider alter like @berdir as suggested in comment 5, so if the flood service is the default database backend we replace it by the new one in flood_unblock.services.yml and if it is another one, do nothing because the webmaster/administrator has enough knowledge to use another backend and has access to the settings.php/services.yml files and know what to do inside.

rob c’s picture

I'm working on a new flood project and i faced the same issue.

The (real) problem (from what i found so far): the storage of the flood records dictates the way flood_unblock deals with them (the @flood passed to the FloodUnblockManager). I believe this has to change for the current issue to work correctly.

I think instead of overriding the flood storage + having all these contrib modules adopt a part of the flood_unblock code (and maintain it), the classes should remain in A. a separate flood storage module or B. be added in flood_unblock (think redis, memcache, etc, yada) - and - (more important): the storage and display should be separated, so flood_unblock can react to whatever is configured.

I believe the flood_unblock module should adopt the choice we made in our flood project: act on the @flood that's passed to the handler - and not use it. Load the corresponding 'flood_unblock process class' from what's passed via the @flood, instead of overloading the thing that needs to run fast with additional code only required for 'processing' the records, like it would do with the current patch (+ all the related other complexities).

Saves a lot of work and this also works without module dependencies. Just make sure the class that core flood uses works, if that's broken, too bad. (then just return a message: unable to load handler or something, currently it returns the empty row message only, but that's details) (also no need for a module exists, but can't hurt in the manager init)

So i believe when Drupal+Redis is installed, and configured, flood_unblock should load the corresponding 'flood unblock process class' for it (or whatever you want to call it) and not override + use the flood storage class itself passed via @flood, but could be wrong ;)

[edit: render>process, fits better to what it actually does]

rob c’s picture

rob c’s picture

After reviewing some more bits n pieces, other modules, rethink it all again, i wonder if we can not just implement a factory for retrieving the 'flood_unblock method class' bases on whatever is loaded in the flood service (if those a separated like i proposed previously).

(Where the 'flood_unblock method class' corresponds to whatever is loaded in the flood service, so a class for each in flood_unblock.)

Then the manager can just be amended with the result from that factory.

rob c’s picture

To answer my own question:

No we can't use a factory if we want to inject the connection etc. Did some testing with some concept code and have some more ideas. Also attempted submodules for storage backends and more.

I propose to separate the flood storage & the flood unblock storage.

Make flood_unblock use the database by default and let sites override that behaviour in their site's services file (like to override the core flood service) (cause really, what would break this: a site with the flood service set to (for example) Redis - and - the database schema for the flood table not installed, e.g. a super custom setup, that table is always created by default). It will render an empy table, but that's the worse that could happen on a default install. + We could test for the class and report on the reports page if the service for flood does not match the configured service for flood_unblock. (this is what i actually do in my flood project now, seems to work ok).

Then we can create storage classes for each we want flood_unblock to support and make the flood unblock manager accept that instance as a param. So we can just call: manager->listBlockedIps() (etc) on the form/etc.

So yes, (soft) dependencies, but i think way better maintainable then adding classes to each contrib project (redis/memcache/couchbase/etc - list continues to grow).

What do you guys think about this last proposal? ^^

andypost’s picture

Looks the service provider is better approach because when flood backend is overriden (it happens once of container build) that's exactly where flood_unblock should check "real" (current) service class for flood and try to find compatible class to query (list) and unblock (unset) methods

andrewbelcher’s picture

Could this be handled by using a service provider to inspect the flood backend and add an appropriate manager dynamically rather than defining statically in flood_unblock.services.yml? Flood unblock would have to provide the managers itself (or other modules could ship with the manager and themselves add it via a service provider). That gets round hard dependencies in either direction.

Edit; Just realised I didn't read the most recent comment properly, sorry!

andrewbelcher’s picture

Assigned: fabianderijk » Unassigned
StatusFileSize
new12.99 KB

This is a really rough implementation of a swappable backend with redis implementation. Issues include:

  • No tests
  • Not overly happy with having to actually load the flood service to check what backend to use...
  • Could maybe do with some namespace changes to better structure the managers - all just in src at the moment.
  • There's quite a lot of copy/pasted code. It might be better to either use a base class or a decorator for things like user details, location etc.
andrewbelcher’s picture

Version: 8.x-1.x-dev » 3.0.x-dev
andrewbelcher’s picture

StatusFileSize
new13.34 KB

Perhaps not entirely surprisingly, loading the service caused errors on install... Here's switching to sniffing from the definition. Perhaps #3174906: Consolidate flood backend might make it cleaner!

Marko B’s picture

Hi, wondering why is this patch on 3.0.x version and not on 3.1.x and also I tried getting this to apply on 3.0.x but it doesnt work. I am bit confused why dont we follow branch release name with tags, is this a bug or proper way to use this versioning.

catch’s picture

Project: Flood Unblock » Flood control
Version: 3.0.x-dev » 2.1.1
Status: Needs review » Needs work

Since this module is being discontinued/merged with flood_control, moving this issue over there. Will need a re-roll for file name changes (at least).

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new12.43 KB

Untested re-roll.

catch’s picture

StatusFileSize
new12.43 KB

Couple of missed used statements.

catch’s picture

StatusFileSize
new14.9 KB

There are more issues here than just a re-roll.

The API for flood_unblock module that this patch is written against uses floodUnblockClearEvent($event, $identifier). This would work fine for Redis (although I'm not sure which branch it was written against).

The API for flood_control uses floodUnblockClearEvent($event, $identifier) - Redis doesn't store an fid.

Some extra changes in this patch to record progress, but @todos:

1. Is it OK to change the API of FloodUnblockManagerInterface here (i.e. do we need a new method to clear events and leave the old one intact or similar).

2. The admin form still needs updating.

catch’s picture

StatusFileSize
new9.61 KB
new18.91 KB

OK a bit more work.

Implemented ::getEntries() for FloodUnblockManagerDatabase

Simplified the form so that it can rely on the ::getEntries() method.

I've only tested this locally with the database backend but posting progress. Will do some manual testing with redis tomorrow hopefully.

catch’s picture

StatusFileSize
new4.67 KB
new19.96 KB

More progress.

Redis backend now works.

::getEvents() doesn't belong on FloodUnblockManagerInterface - it's just a mapping for the UI. Have copied this to the form class but other references not converted yet.

Removed the smart IP mapping for now - this should IMO be brought back in a different issue that only attempts to check IP location for actual IP addresses (probably depending on the flood event) - right now it's looking up IP location for arbitrary strings.

Some other bits like getIdentifiers() that I think should probably be factored away rather than implemented with Redis.

grimreaper’s picture

Assigned: Unassigned » grimreaper

Hello,

Original issue reporter here :), Thanks a lot for the work done on this issue!

I will create a MR for easier review and try to update myself on what has been going on here.

grimreaper’s picture

Issue tags: +GlobalContributionWeekend2021

grimreaper’s picture

Status: Needs review » Needs work

If I switch from Redis to database backend (with a website installed with Redis directly), I obtain the following error:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.flood' doesn't exist: SELECT "flood"."event" AS "event", "flood"."identifier" AS "identifier", COUNT(*) AS "flood_count" FROM {flood} "flood" WHERE "expiration" > :db_condition_placeholder_0 GROUP BY event, identifier; Array ( [:db_condition_placeholder_0] => 1612017138 ) in Drupal\flood_control\Form\FloodUnblockAdminForm->buildForm() (line 131 of modules/custom/flood_control/src/Form/FloodUnblockAdminForm.php).

I am persuing testing.

grimreaper’s picture

When using the database backend, when the user is blocked, the status column is correctly updated.

When using the redis backend, when the user is blocked, the status column is not updated.

grimreaper’s picture

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

MR updated.

Ok for me!

I can't RTBC because I changed some code.

rachel_norfolk’s picture

Issue tags: -GlobalContributionWeekend2021 +ContributionWeekend2021

Just doing a little tag tidying. Nice work everyone!!

mkolar’s picture

Hi, thanks everybody! I will try this probably tomorrow on our project.

afi13’s picture

Status: Needs review » Reviewed & tested by the community

Ok for me too! Works on our projects.

hmdnawaz’s picture

StatusFileSize
new23.14 KB

Used the patch from the MR.

mkolar’s picture

i can confirm it works (#36) on our project.

catch’s picture

StatusFileSize
new23.84 KB

Rebased the PR, and adding a new patch.

fabianderijk’s picture

@catch, thanks for all the good work. I've just checked the merge request, and everything seems fine. But what I notice is that the filters, tablesorting and such has been removed (https://git.drupalcode.org/project/flood_control/-/merge_requests/16/dif...) in your patch.

Did you do this with a specific reason?

catch’s picture

@fabianderijk alternative backends can't really support tablesort and filters, or not in an efficient way. It might be possible to add them back just for the database backend.

somersoft’s picture

Can it also support SMS Framework?

Notice: Undefined index: sms.verify_phone_number in Drupal\flood_control\Form\FloodUnblockAdminForm->buildForm() (line 137 of /app/web/modules/contrib/flood_control/src/Form/FloodUnblockAdminForm.php)

socialnicheguru’s picture

Status: Reviewed & tested by the community » Needs work

This no longer applies.

Via composer:

- Installing drupal/flood_control (2.2.3): Extracting archive
- Applying patches for drupal/flood_control
https://www.drupal.org/files/issues/2021-09-14/2928007-38.patch (Support external Flood)
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2021-09-14/2928007-38.patch

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

mrdalesmith’s picture

Status: Needs work » Needs review
StatusFileSize
new25.28 KB

Struggling to get the MR branch working, so here's a rerolled patch for someone else to figure it out with :)

mkolar’s picture

Status: Needs review » Reviewed & tested by the community

Hi! I've tested Drupal 9.3.6 + 2.2.3 + patch #45 and it works with Redis!

monymirza’s picture

Version: 2.1.1 » 2.2.x-dev
Status: Reviewed & tested by the community » Needs work

Needs reroll for 2.2.4

lisastreeter’s picture

Reroll for 2.2.4. Doesn't include implementation of new method needed for Drush commands.

vanilla-bear made their first commit to this issue’s fork.

vanilla-bear’s picture

Hello !

New patch with redis and databases seems working good.

Based from last stable release branch 2.2.4

Sorry I try to use issue fork system but i don't succeed to use it.

lisastreeter’s picture

StatusFileSize
new30.69 KB

Rerolled flood_control-support_external_flood-2928007-52.patch for 2.3.0

lisastreeter’s picture

StatusFileSize
new24.4 KB

Oops! Previous patch had a misnamed file. Fixed version attached.

vanilla-bear’s picture

Version: 2.2.x-dev » 2.3.0

vanilla-bear’s picture

New patch with a new branch from fork: flood_control-2928007

The patch is well applied with this link: https://git.drupalcode.org/project/flood_control/-/merge_requests/36.diff

i implement fetchIdentifiers function for database and redis class.

I completed this issue to have a more readable user name.

I have not tested the patch with the database project.

fl-49’s picture

Thanks for this module. But...

I maintain a site that uses redis. The Flood Control module v2.3.0, with the diff file patch applied from #57, works correctly displaying flood control info and enabling deleting these from redis.

Updating to Flood Control v2.3.2, this patch can no longer be applied. Composer results in this error:
Could not apply patch! Skipping. The error was: Cannot apply patch https://git.drupalcode.org/project/flood_control/-/merge_requests/36.diff

I also tried the patch from #54, with the same fail result.

I would try to offer a suggested fix, but I don't see where the fail is.

Will this patch be updated, and/or merged with a future version of Flood Control?

will_frank’s picture

StatusFileSize
new26.25 KB

We have produced a new patch that works for us with Redis on Flood control 2.3.2.
See attached flood_control_2.3.2.patch.

will_frank’s picture

sergeimalyshev’s picture

StatusFileSize
new33.21 KB

Added fix for misleading "blocked status" on custom events.

sergeimalyshev’s picture

Status: Needs work » Needs review
will_frank’s picture

With Drupal 10.0.9, and Flood control 2.3.2
with this patch (62) flood_control-support_external_flood-2928007-62.patch
I'm getting this following error:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "flood_control.flood_unblock_manager". in Drupal\Component\DependencyInjection\Container->get() (line 157 of core/lib/Drupal/Component/DependencyInjection/Container.php).
Drupal\flood_control\Form\FloodUnblockAdminForm::create(Object) (Line: 28)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('\Drupal\flood_control\Form\FloodUnblockAdminForm') (Line: 48)
Drupal\Core\Controller\HtmlFormController->getFormObject(Object, '\Drupal\flood_control\Form\FloodUnblockAdminForm') (Line: 58)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 686)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

will_frank’s picture

To add a bit to my previous comment, I've been getting the same error using
flood_control_2.3.2.patch (see #59) but the patch worked on Drupal 9.
Something is going on with dependency injection but I haven't been able to figure
out what the problem is. I hope you can figure it out for
patch (62) flood_control-support_external_flood-2928007-62.patch so it can work
on Drupal 10.

sonneworks’s picture

I have the same issue on D10
In the FloodControlServiceProvider::alter method ... instead of setting a new service definition i'm updating the existing one... which seems to work:

$container->getDefinition('flood_control.flood_unblock_manager')
  ->setClass(FloodUnblockManagerRedis::class)
  ->setArguments( [
        new Reference('redis.factory'),
        new Reference('flood'),
        new Reference('config.factory'),
        new Reference('entity_type.manager'),
        new Reference('messenger'),
      ]);

not sure why

will_frank’s picture

sonneworks - I'm eager to try your new fix but so far have not been able to get
it to work. Could you either:
post your entire new FloodControlServiceProvider::alter method
or
if you have produced a new patch based on this fix could you post that? thanks will_frank

will_frank’s picture

@sonneworks - is it possible that you might have changed other parts of the code
besides the FloodControlServiceProvider::alter method to get it to work?

One idea is that if you don't have a full patch file ready, perhaps you could
just zip up your entire flood_control module (all the files) and email it to me
at fwilliams7070@gmail.com and I'll try it - and if it works I could produce a patch.

will_frank’s picture

StatusFileSize
new26.27 KB

@sonneworks
We have succeeded in creating a new patch based on your idea. Many thanks.
This works on Drupal 10. Likely this patch only will work with sites that are using
redis.

pjovanovic’s picture

I took the patch #69 and aligned the method signature of the FloodUnblockManager::fetchIdentifiers with the interface method.

Edit: removed Patch beacuse this class is not used anymore. I recommend to remove the FloodUnblockManager.php file, in order to get rid
of legacy code.

pjovanovic’s picture

sonneworks’s picture

@will_frank sorry, was on holiday, didn't have access to codebase :)

kalaiyarasithangavel’s picture

Hi @will_frank , flood_control_2.3.2_d10.patch not working for flood_control 2.3.3.

version: 2.3.3

will_frank’s picture

@KalaiyarasiThangavel yes you're right. I've been working trying to produce
a new patch for flood_control 2.3.3 but so far without success. If anyone has
a solution I would love to see it.

will_frank’s picture

StatusFileSize
new30.44 KB

I have produced a new patch that works for us on Drupal core 10.1.4
and Flood control 2.3.3.
see
flood_control_2.3.3_d10.patch (30.44 KB)

kalaiyarasithangavel’s picture

Thank You @will_frank . The patch works fine.

willibautista’s picture

Hi, I am getting the same error even after applying the #75 patch.

The website encountered an unexpected error. Please try again later.

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "flood_control.flood_unblock_manager". in Drupal\Component\DependencyInjection\Container->get() (line 157 of core/lib/Drupal/Component/DependencyInjection/Container.php).
Drupal\flood_control\Form\FloodUnblockAdminForm::create(Object) (Line: 28)
Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('\Drupal\flood_control\Form\FloodUnblockAdminForm') (Line: 48)
Drupal\Core\Controller\HtmlFormController->getFormObject(Object, '\Drupal\flood_control\Form\FloodUnblockAdminForm') (Line: 58)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Drupal version: 10.5.1
Flood_control: 2.3.3

I really appreciate your support

elc’s picture

StatusFileSize
new28.07 KB

The issue forks for this are pretty wildly broken. I tried to see if I could rescue at least one of them, but in reality it looks like they should all be closed off and deleted.

Here's a re-roll of the patch from the current HEAD which also includes an update - the patch in #75 remove it?

elc’s picture

Version: 2.3.0 » 2.3.x-dev
Status: Needs review » Needs work
Issue tags: -ContributionWeekend2021 +Needs issue summary update

Returning to Needs Work as there are a number of changes included recently in HEAD which have not been included in the change.

elc’s picture

Work in progress.

Should work for redis OK - just doesn't have creation/expire times showing at present. No ability to filter.

Database back end is completely untested. Interface needs to be updated to pass in filtering options so no filtering atm.

Hey @WilliBautista, Your issue seems to be deeper than just the patch as the server which is present with or without this patch is what your site is complaining about. Flush caches? Patch from HEAD?

elc’s picture

StatusFileSize
new37.12 KB
new4.56 KB

I ran into the same problem as comments #64 & #77, finally settling on the solution in #66 with some additional guards since I had an out of order xServiceProvider occurrence where the definition did not exist before trying alter it. The issue only manifest itself after restarting my cli session and prevented the site from working until I disabled the alter completely, flushed redis completely, restarted apache and php-fpm, and then flushed caches. Discovered the FloodUnblockManagerUnknown class needed some more method stubs.

No other significant changes.

batigolix’s picture

Issue tags: +finalist-sprint
sergeimalyshev’s picture

StatusFileSize
new38.33 KB

I have updated the patch for the last dev version of module.

sergeimalyshev’s picture

Status: Needs work » Needs review
alexrayu’s picture

Hello Sergei,
Thanks for your work!
#83 created an error in `FloodUnblockManagerDatabase` re "not in GROUP".
Please check the patch including the fixes attached.

alexrayu’s picture

StatusFileSize
new38.42 KB

Patch from #85 reports as "corrupted".

andreasderijcke’s picture

Confirming that patch #86 works as expected on a D10.1.7 and D10.2.3.

chist’s picture

Hi, thanks everybody! I received some error and warning when testing patch #86 on D10.1.6 native database backend:
InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).

Warning: Undefined array key "value" in Drupal\flood_control\Form\FloodUnblockAdminForm->buildForm() (line 189 of modules/contrib/flood_control/src/Form/FloodUnblockAdminForm.php).
Drupal\flood_control\Form\FloodUnblockAdminForm->buildForm(Array, Object)

Used $results[$key]["value"] instead of $results[$identifier]["value"] in FloodUnblockManagerDatabase::fetchIdentifiers.

batigolix’s picture

A a maintainer, I have been monitoring this issue for a while.

I think that there are still major problems with this patch:
- Code has been copied in the past from FloodUnblockManager to new classes (FloodUnblockManagerBase & FloodUnblockManagerDatabase). After that moment FloodUnblockManagerBase was changed and improved, but those changes were not transferred to the code in FloodUnblockManagerBase & FloodUnblockManagerDatabase, resulting in the code in those files to miss certain features and improvements. The same happened with code that was copied from FloodUnblockAdminForm.php
- Having a default manager that is 'unknown' is confusing to me. We better assume that we have a database connection and make the original Manager the
default again. In that case we don't need FloodUnblockManagerUnknown.php

I propose to introduce the External Flood Support in two steps, using 2 different issues:
- 1. Add the generic FloodUnblockManager. This will be achieved by adding the generic FloodUnblockManagerBase and the database specific FloodUnblockManagerDatabase. This should be done while ensuring that everything keeps functioning as it does in the latest release.
#3437860: Make FloodUnblockManager generic
- 2. Add the Redis FloodUnblockManager. This will be achieve by adding the FloodUnblockManagerRedis
#3437875: Add Redis support

batigolix’s picture

Status: Needs review » Postponed (maintainer needs more info)
anybody’s picture

Title: Support external Flood » Support external Flood (Redis, etc.)

Oh man, I just ran into this and was searching for an hour, why IPs are blocked, but the list at /admin/people/flood-unblock and the flood database is empty -.-

The reason is: The project uses redis as caching backend (#3192286: Flood unblock page is always empty with redis module)

Just wanted to point out here, that this is really tricky currently and not easy to find, if you didn't set up the project and are not aware of this special case.
I totally agree with @batigolix in #89 but perhaps we should first make this more visible, until it is solved?
We could also treat this as bug, while I understand that Redis etc. are seen as bonus.

I hope what happened to me doesn't happen to others. For now I'll exclude flood from Redis. Documented here: https://www.drupal.org/project/flood_control/issues/3192286#comment-1396...

anybody’s picture

catch’s picture

Status: Postponed (maintainer needs more info) » Needs work

Needs work seems like a better status than needs more info here - the problem is known, the question is how best to implement the fix for it.

gpz’s picture

Updated the last patch to support the new filter "Only blocked"
I did this the same way it is done in "dev" if I'm right.
(This means it's display filter only, not a request filter)

batigolix’s picture

The code in the patches in this issue is missing a lot of the improvements that were made in the last years (among them the new filter "Only blocked").

I explained this in #89

I created a new patch that includes all improvements (including the new filter "Only blocked") plus the code that makes the flood unblock generic. See #3437860: Make FloodUnblockManager generic

There is an open issue for adding Redis support #3437875: Add Redis support

batigolix’s picture

Status: Needs work » Postponed

Please do no update the patches in because they are outdated.

I put this issue on hold until #3437860: Make FloodUnblockManager generic is fixed.

andypost’s picture

Status: Postponed » Needs work

blocker is fixed

batigolix’s picture

Status: Needs work » Postponed

Sorry, I was not clear. #3437875: Add Redis support also needs to be fixed.

batigolix’s picture

#3437875: Add Redis support can be reviewed. We just pushed a couple of commits that allow the use of Redis.
This needs thorough testing. Any help with testing this, would be greatly appreciated.

batigolix’s picture

Status: Postponed » Closed (duplicate)

The issue for adding Redis support is #3437875: Add Redis support