Too few arguments to function: AutobanController

Created on 1 November 2024, about 2 months ago

Problem/Motivation

Getting this error:

ArgumentCountError:
Too few arguments to function Drupal\autoban\Controller\AutobanController::__construct(), 0 passed in /var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/Controller/ControllerBase.php on line 109 and exactly 1 expected

at /var/www/html/websites/drupal9/master/web/modules/contrib/autoban/src/Controller/AutobanController.php:33
at Drupal\autoban\Controller\AutobanController->__construct()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/Controller/ControllerBase.php:109)
at Drupal\Core\Controller\ControllerBase::create()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php:28)
at Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/Controller/ControllerResolver.php:116)
at Drupal\Core\Controller\ControllerResolver->createController()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/Controller/ControllerResolver.php:68)
at Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/Controller/ControllerResolver.php:84)
at Drupal\Core\Controller\ControllerResolver->getController()
(/var/www/html/websites/drupal9/master/web/modules/contrib/tracer/src/Controller/TraceableControllerResolver.php:35)
at Drupal\tracer\Controller\TraceableControllerResolver->getController()
(/var/www/html/websites/drupal9/master/vendor/symfony/http-kernel/HttpKernel.php:164)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
(/var/www/html/websites/drupal9/master/vendor/symfony/http-kernel/HttpKernel.php:76)
at Symfony\Component\HttpKernel\HttpKernel->handle()
(/var/www/html/websites/drupal9/master/web/modules/custom/sbn/src/Middleware/Redirect.php:19)
at Drupal\sbn\Middleware\Redirect->handle()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/StackMiddleware/Session.php:58)
at Drupal\Core\StackMiddleware\Session->handle()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:48)
at Drupal\Core\StackMiddleware\KernelPreHandle->handle()
(/var/www/html/websites/drupal9/master/web/core/modules/page_cache/src/StackMiddleware/PageCache.php:106)
at Drupal\page_cache\StackMiddleware\PageCache->pass()
(/var/www/html/websites/drupal9/master/web/core/modules/page_cache/src/StackMiddleware/PageCache.php:85)
at Drupal\page_cache\StackMiddleware\PageCache->handle()
(/var/www/html/websites/drupal9/master/web/modules/contrib/advban/src/AdvbanMiddleware.php:57)
at Drupal\advban\AdvbanMiddleware->handle()
(/var/www/html/websites/drupal9/master/web/core/modules/ban/src/BanMiddleware.php:50)
at Drupal\ban\BanMiddleware->handle()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:48)
at Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
(/var/www/html/websites/drupal9/master/web/modules/contrib/tracer/src/StackMiddleware/TracesMiddleware.php:38)
at Drupal\tracer\StackMiddleware\TracesMiddleware->handle()
(/var/www/html/websites/drupal9/master/web/modules/contrib/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php:40)
at Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:51)
at Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php:51)
at Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
(/var/www/html/websites/drupal9/master/web/core/lib/Drupal/Core/DrupalKernel.php:704)
at Drupal\Core\DrupalKernel->handle()
(/var/www/html/websites/drupal9/master/web/index.php:19)

I searched the issue queue for ArgumentCountError and only found this: https://www.drupal.org/project/autoban/issues/3253490 β†’ which was resolved 3 years ago and doesn't appear to be the same issue.

Steps to reproduce

I installed AutoBan 8.x-1.10 on Drupal core 10.1.6 system. Went to /admin/reports/dblog on my site. Under operations, if I click AutoBan or CoreBan links, I get the above error.

Proposed resolution

I have AutoBan Version: 8.x-1.9 working successfully on an almost duplicate site running Drupal 10.1.5 core. Not sure how to proceed from here.

πŸ› Bug report
Status

Active

Version

1.10

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States somebodysysop

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @somebodysysop
    • 576aabd7 committed on 8.x-1.x
      Issue #3485128: Too few arguments to function: AutobanController
      
  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @somebodysysop, thank you for report.
    Please, check on the latest dev version.

  • πŸ‡ΊπŸ‡ΈUnited States somebodysysop

    Yes, thank you. Installed the latest dev version and now the dblog links work as expected.

    One difference between 8.x-1.10 and dev that I noticed, in case it helps:

    In 8.x-1.10, whitelisted IPs in the dblog do NOT have the Advanced Ban, Advanced Ban (range), Core Ban links.

    In dev version, the links DO appear next to the whitelisted IPs.

  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @somebodysysop, thanks for testing.
    I can't reproduce the whitelist issue for Drupal 10.1.6 and 11 versions.

    The logic for adding the Autobank links is:

          $ip = $dblog->hostname;
          if (!empty($ip) && $autobanController->canIpBan($ip)) {
            // Retrieve Autoban Ban Providers list.
            $providers = [];
            $banManagerList = $autobanController->getBanProvidersList();
            if (!empty($banManagerList)) {
              $destination = $this->getDestinationArray();
              foreach ($banManagerList as $id => $item) {
                $url_item = Url::fromRoute('autoban.direct_ban', [
                  'ips' => $ip,
                  'provider' => $id,
                ], [
                  'query' => [
                    'destination' => $destination['destination'],
                  ],
                ]);
                $url_link = Link::fromTextAndUrl($item['name'], $url_item);
                $providers[$id] = $url_link->toString();
              }
            }
          }

    The main checking is autobanController->canIpBan($ip) . It didn't change after 8.1.10.
    The function calls the whitelist checking function:

        if ($this->whitelistIp($ip)) {
          return FALSE;
        }

    Perhaps in your particular case this function is failing and needs to be fixed.

Production build 0.71.5 2024