From c7b95174f68320930553f6ee1dfcec24415ec65e Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:52:29 -0400 Subject: [PATCH] Process fixity as user 1 --- src/Plugin/QueueWorker/ProcessSourceWorker.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Plugin/QueueWorker/ProcessSourceWorker.php b/src/Plugin/QueueWorker/ProcessSourceWorker.php index 77e5266..58c8d4b 100644 --- a/src/Plugin/QueueWorker/ProcessSourceWorker.php +++ b/src/Plugin/QueueWorker/ProcessSourceWorker.php @@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Queue\QueueWorkerBase; use Drupal\Core\Queue\RequeueException; use Drupal\dgi_fixity\FixityCheckServiceInterface; +use Drupal\user\Entity\User; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -59,6 +60,10 @@ class ProcessSourceWorker extends QueueWorkerBase implements ContainerFactoryPlu * {@inheritdoc} */ public function processItem($data) { + // To avoid expensive access calls + $account_switcher = \Drupal::service('account_switcher'); + $account_switcher->switchTo(User::load(1)); + /** @var \Drupal\dgi_fixity\FixityCheckServiceInterface $fixity */ $fixity = \Drupal::service('dgi_fixity.fixity_check'); $view = $fixity->source($data, 1000); @@ -74,6 +79,8 @@ class ProcessSourceWorker extends QueueWorkerBase implements ContainerFactoryPlu if (count($view->result) !== 0) { throw new RequeueException(); } + + $account_switcher->switchBack(); } }