- Issue created by @sidgrafix
Can confirm. Same error for me.
I have core ban module activated.-----------------------------
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\autoban\Controller\AutobanController->getBannedIp() (line 54 of /code/web/modules/contrib/autoban/src/Controller/AutobanController.php)
#0 /code/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'trim(): Passing...', '/code/web/modul...', 54)
#1 [internal function]: _drupal_error_handler(8192, 'trim(): Passing...', '/code/web/modul...', 54)
#2 /code/web/modules/contrib/autoban/src/Controller/AutobanController.php(54): trim(NULL)
#3 /code/web/modules/contrib/autoban/src/AutobanBatch.php(24): Drupal\autoban\Controller\AutobanController->getBannedIp('rule8')
#4 /code/web/modules/contrib/autoban/autoban.module(50): Drupal\autoban\AutobanBatch::ipBan('rule8', Array)
#5 [internal function]: autoban_cron(Object(Drupal\ultimate_cron\Entity\CronJob))
#6 /code/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(325): call_user_func('autoban_cron', Object(Drupal\ultimate_cron\Entity\CronJob))
#7 /code/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(471): Drupal\ultimate_cron\Entity\CronJob->invokeCallback()
#8 /code/web/modules/contrib/ultimate_cron/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php(213): Drupal\ultimate_cron\Entity\CronJob->run(Object(Drupal\Core\StringTranslation\TranslatableMarkup))
#9 /code/web/modules/contrib/ultimate_cron/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php(334): Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher->launch(Object(Drupal\ultimate_cron\Entity\CronJob))
#10 /code/web/modules/contrib/ultimate_cron/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php(309): Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher->runThread('222908', 1, Array)
#11 /code/web/modules/contrib/ultimate_cron/src/UltimateCron.php(64): Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher->launchJobs(Array)
#12 /code/web/modules/contrib/ultimate_cron/src/ProxyClass/UltimateCron.php(70): Drupal\ultimate_cron\UltimateCron->run()
#13 /code/web/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\ultimate_cron\ProxyClass\UltimateCron->run()
#14 [internal function]: Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#15 /code/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#16 /code/vendor/symfony/http-kernel/HttpKernel.php(103): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...')
#17 /code/vendor/stack/builder/src/Stack/StackedHttpKernel.php(32): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\big_pipe\Render\BigPipeResponse))
#18 /code/web/core/lib/Drupal/Core/DrupalKernel.php(697): Stack\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\big_pipe\Render\BigPipeResponse))
#19 /code/web/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\big_pipe\Render\BigPipeResponse))
#20 {main}
---------------------------------Drupal 9.5.2 - PHP 8.1.14 - 10.4.25-MariaDB-log
- πΊπ¦Ukraine goodboy Kharkiv, Ukraine
Fixed in dev version, please test
Still same message using Drupal 9.5.3 and the dev version
- πΊπΈUnited States sidgrafix
@goodboy
Tested against dev version:
The initial error:
Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\autoban\Controller\AutobanController->getBannedIp() (line 54 of /var/www/html/web/modules/contrib/autoban/src/Controller/AutobanController.php)
--> is goneHowever this brings on the new error I mentioned (after my initial test by commenting out the new feature at line 54)
as well as line 144-147 (the new $date addition, where $window was used from line 54) $date = strtotime($window); if ($date) { $query->condition('log.timestamp', $date, '>='); }
which is:
Deprecated function: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in Drupal\autoban\Controller\AutobanController->getBannedIp() (line 144 of /var/www/html/web/modules/contrib/autoban/src/Controller/AutobanController.php)
I'm adding a patch I created for myself for version 1.8 (Note: this basically disables the newly added feature)
-
goodboy β
committed f7835f3e on 8.x-1.x
Issue #3335947 by sidgrafix, binkdot5: Deprecated function: trim():...
-
goodboy β
committed f7835f3e on 8.x-1.x
- πΊπ¦Ukraine goodboy Kharkiv, Ukraine
@sidgrafix, I tried to keep the window feature and made a comit again, Please test
- Status changed to Needs review
almost 2 years ago 1:39pm 11 February 2023 - πΊπΈUnited States sidgrafix
@goodboy
Tested against dev version appears to take care of the errors that were previously being logged each time Autoban is triggered by cron.
However after reviewing your commit I'm not entirely sure this actually solves the underlying problem...
$window = !empty($entity->window) ? trim($entity->window) : NULL;
appears to just make it so $window "if empty" will not be passed thereforif ($window) { $date = strtotime($window); if ($date) { $query->condition('log.timestamp', $date, '>='); }}
won't run, as there is no $window set, thus no errors are logged.Maybe I'm wrong, but I did have the new setting set "Default window" to
1 hour ago
in Autoban settings when the change was introduced and I was getting the error notices. I think the underlying problem is elsewhere before$window = !empty($entity->window) ? trim($entity->window) : NULL;
is even evaluated (at least for what I'm seeing) - but maybe I'm wrong. I haven't had time or tried to backtrack thru the code to find out were $entity->window should be coming from to confirm anything.This does absolutely stop the errors from being logged, but I'm not entirely sure the actual features functions are working! So I figured I'd mention it.
Just update and run cron, no errors showing as of yet so seems to have fixed the issue. Many Thanks
- π«π·France quimic Paris
I get the debug messages (Drupal 9.5.9) but I cannot seem to apply the #5 patch. It gets rejected.
- Assigned to koston022
Hello. I added condition for $entity->referer to fix Deprecated function: trim(): Passing null to parameter.
$referer = !empty($entity->referer) ? trim($entity->referer) : NULL;