\Drupal\Core\Flood\MemoryBackend::isAllowed() does not work if no event registrations happened before:

$memory_flood->isAllowed('user.failed_login_ip', 50, 3600); // Exception: 'Undefined index: user.failed_login_ip'
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

edwardaa created an issue. See original summary.

edaa’s picture

Status: Active » Needs review
FileSize
1.39 KB

Failing test.

edaa’s picture

New patch fixed the issue.

The last submitted patch, 2: 2909952-2-failing-test.patch, failed testing. View results

edaa’s picture

Issue summary: View changes
edaa’s picture

edaa’s picture

Take into account both the event name and user identifier.

edaa’s picture

Title: Flood MemoryBackend::isAllowed() throws exception: 'Undefined index: user.failed_login_ip' » Flood MemoryBackend::isAllowed() throws exception: 'Undefined index: xxx'
FileSize
2.09 KB
795 bytes

Fix #7 wrong interdiff file.

edaa’s picture

It's better to return $threshold > 0 than TRUE.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @edwardaa! This fix totally makes sense for me. It is not allowed when you have a threshold of 0.

catch’s picture

Uploading a test-only patch so we can see the test fails. Otherwise looks good but including a test-only patch helps things get committed quicker.

The last submitted patch, 11: 2909952-9-test-only.patch, failed testing. View results

  • catch committed 4e2d3ba on 8.5.x
    Issue #2909952 by edwardaa: Flood MemoryBackend::isAllowed() throws...

  • catch committed c99427e on 8.4.x
    Issue #2909952 by edwardaa: Flood MemoryBackend::isAllowed() throws...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

dawehner’s picture

Thank you catch!

Status: Fixed » Closed (fixed)

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