Browse Source

Process fixity as user 1

pull/14/head
Chris MacDonald 11 months ago
parent
commit
c7b95174f6
  1. 7
      src/Plugin/QueueWorker/ProcessSourceWorker.php

7
src/Plugin/QueueWorker/ProcessSourceWorker.php

@ -6,6 +6,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueWorkerBase; use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\Core\Queue\RequeueException; use Drupal\Core\Queue\RequeueException;
use Drupal\dgi_fixity\FixityCheckServiceInterface; use Drupal\dgi_fixity\FixityCheckServiceInterface;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
@ -59,6 +60,10 @@ class ProcessSourceWorker extends QueueWorkerBase implements ContainerFactoryPlu
* {@inheritdoc} * {@inheritdoc}
*/ */
public function processItem($data) { 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 */ /** @var \Drupal\dgi_fixity\FixityCheckServiceInterface $fixity */
$fixity = \Drupal::service('dgi_fixity.fixity_check'); $fixity = \Drupal::service('dgi_fixity.fixity_check');
$view = $fixity->source($data, 1000); $view = $fixity->source($data, 1000);
@ -74,6 +79,8 @@ class ProcessSourceWorker extends QueueWorkerBase implements ContainerFactoryPlu
if (count($view->result) !== 0) { if (count($view->result) !== 0) {
throw new RequeueException(); throw new RequeueException();
} }
$account_switcher->switchBack();
} }
} }

Loading…
Cancel
Save