@michael.garrido

Account created on 30 November 2023, 7 months ago
#

Recent comments

I can also confirm this issue happens with Flood Control and Drupal Shield module enabled, using Drupal 10.2.6. Doesn't seem to occur in Drupal 10.1.8.

This seems to be due to the isIpWhitelisted function trying to call the flood_control_get_whitelist_ips function that is defined in the flood_control.module file:

<?php
...
protected function isIpWhitelisted(string $ipAddress = ''): bool {
    $request = $this->requestStack->getCurrentRequest();

    if ($request && !$ipAddress) {
      $ipAddress = $request->getClientIp() ?? '';
    }

    // Gets the values from the config.
    $ipsWhiteList = flood_control_get_whitelist_ips();
.....
?>

it seems to be failing to resolve that particular function when called from that location. Oddly enough, in Form/FloodControlSettingsForm.php, the code does a similar call:

<?php
...
 public function validateForm(array &$form, FormStateInterface $form_state) {
    // Validating whitelisted ip addresses.
    $whitelistIps = flood_control_get_whitelist_ips($form_state->getValue('ip_white_list'));
    // Checking single ip addresses.
    if (!empty($whitelistIps['addresses'])) {
      foreach ($whitelistIps['addresses'] as $ipAddress) {
        if (!filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) {
          $form_state->setErrorByName('ip_white_list', $this->t('IP address %ip_address is not valid.', ['%ip_address' => $ipAddress]));
        }
      }
    }
.....
?>

But that one does NOT cause an error.

The error seems to partly stem from the namespace causing PHP to look in the wrong spot, IE its looking for Drupal\flood_control\flood_control_get_whitelist_ips(), but since that function isn't in the Drupal/flood_control namespace, it fails. However, I did try doing something like:

<?php
...
protected function isIpWhitelisted(string $ipAddress = ''): bool {
....
$ipsWhiteList = \flood_control_get_whitelist_ips();
....
?>

But it results in essentially the same error (and I'm not sure if that is even that way to go about that anyways).

I'm not sure whether this is an issue with the flood control module itself, or some issue introduced by core that is causing this issue with resolving the function.

Production build 0.69.0 2024