"Argument 1" error message shows repeatedly in logs

Created on 11 November 2020, over 4 years ago
Updated 4 April 2023, about 2 years ago

Log entries show the following error message when the module is triggered by cron:

TypeError: Argument 1 passed to Drupal\purge_users\Services\UserManagementService::purgeUser() must implement interface Drupal\user\UserInterface, null given, called in /PATH/TO/modules/contrib/purge_users/src/Plugin/QueueWorker/PurgeUsersQueueWorker.php on line 27 in Drupal\purge_users\Services\UserManagementService->purgeUser() (line 69 of /PATH/TO/modules/contrib/purge_users/src/Services/UserManagementService.php)
#0 /PATH/TO/modules/contrib/purge_users/src/Plugin/QueueWorker/PurgeUsersQueueWorker.php(27): Drupal\purge_users\Services\UserManagementService->purgeUser(NULL, 'user_cancel_rea...')
#1 /PATH/TO/core/lib/Drupal/Core/Cron.php(180): Drupal\purge_users\Plugin\QueueWorker\PurgeUsersQueueWorker->processItem('8741')
#2 /PATH/TO/modules/contrib/ultimate_cron/src/UltimateCron.php(69): Drupal\Core\Cron->processQueues()
#3 /PATH/TO/modules/contrib/ultimate_cron/src/ProxyClass/UltimateCron.php(70): Drupal\ultimate_cron\UltimateCron->run()
#4 /PATH/TO/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\ultimate_cron\ProxyClass\UltimateCron->run()
#5 /PATH/TO/vendor/symfony/event-dispatcher/LegacyEventDispatcherProxy.php(78): Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy))
#6 /PATH/TO/vendor/symfony/http-kernel/HttpKernel.php(100): Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy->dispatch(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...')
#7 /PATH/TO/vendor/stack/builder/src/Stack/StackedHttpKernel.php(32): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\JsonResponse))
#8 /PATH/TO/core/lib/Drupal/Core/DrupalKernel.php(683): Stack\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\JsonResponse))
#9 /PATH/TO/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\JsonResponse))
#10 {main}
.

πŸ› Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jasonluttrell Washington, DC area

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @adstokoe: Is this still an issue in 8.x-3.x?
    Otherwise we may close this outdated.

  • Status changed to Active almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Well I think the fix still makes sense. I have no better idea to fix this yet.

    Could this please be rerolled as MR against 4.x?

  • First commit to issue fork.
  • πŸ‡«πŸ‡·France mably

    Current code shouldn't trigger the bug anymore. Closing.

      public function processItem($user_id) {
        $account = $this->entityTypeManager->getStorage('user')->load($user_id);
        if (!$account) {
          return;
        }
        $config = $this->configFactory->get('purge_users.settings');
        $method = $config->get('purge_user_cancel_method') !== 'user_cancel_site_policy' ? $config->get('purge_user_cancel_method') : $this->configFactory->get('user.settings')
          ->get('cancel_method');
        $this->purgeUserManager->purgeUser($account, $method);
      }
    
Production build 0.71.5 2024