From 275de2692ec3ae6513e4bba59fd177129fdb017f Mon Sep 17 00:00:00 2001
From: Liam Morland <lkmorlan@uwaterloo.ca>
Date: Sun, 18 Jun 2023 14:16:07 -0400
Subject: [PATCH] Issue #3367389: Add ::accessCheck() call to every
 ::getQuery()

---
 fillpdf.api.php                       | 2 +-
 src/Form/FillPdfFormForm.php          | 2 +-
 tests/src/Traits/TestFillPdfTrait.php | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fillpdf.api.php b/fillpdf.api.php
index fc8e1f5..809e08d 100644
--- a/fillpdf.api.php
+++ b/fillpdf.api.php
@@ -46,7 +46,7 @@ function hook_fillpdf_populate_pdf_context_alter(array &$context): void {
     $webform_submission_storage = \Drupal::entityTypeManager()->getStorage('webform_submission');
     foreach ($context['entity_ids']['webform'] as $webform_id) {
       // Load submission IDs from webform_submission storage.
-      $query = $webform_submission_storage->getQuery()->condition('webform_id', $webform_id);
+      $query = $webform_submission_storage->getQuery()->accessCheck(TRUE)->condition('webform_id', $webform_id);
       $query->condition('uid', $uid);
       $query->condition('in_draft', 0);
       $query->sort('created', 'ASC');
diff --git a/src/Form/FillPdfFormForm.php b/src/Form/FillPdfFormForm.php
index e83f0b9..4ed4b71 100644
--- a/src/Form/FillPdfFormForm.php
+++ b/src/Form/FillPdfFormForm.php
@@ -221,7 +221,7 @@ class FillPdfFormForm extends ContentEntityForm {
         )->toString();
       }
 
-      $entity_ids = $storage->getQuery()->range(0, self::SELECT_MAX + 1)->execute();
+      $entity_ids = $storage->getQuery()->accessCheck(TRUE)->range(0, self::SELECT_MAX + 1)->execute();
       if (count($entity_ids) > self::SELECT_MAX) {
         if (!isset($description)) {
           $description = $this->t('Enter the title of a %type to test populating the PDF template.', [
diff --git a/tests/src/Traits/TestFillPdfTrait.php b/tests/src/Traits/TestFillPdfTrait.php
index b00b726..01adede 100644
--- a/tests/src/Traits/TestFillPdfTrait.php
+++ b/tests/src/Traits/TestFillPdfTrait.php
@@ -128,7 +128,8 @@ trait TestFillPdfTrait {
   protected function getLatestFillPdfForm() {
     $entity_query = $this->container->get('entity_type.manager')
       ->getStorage('fillpdf_form')
-      ->getQuery();
+      ->getQuery()
+      ->accessCheck(TRUE);
     $max_fid_after_result = $entity_query
       ->sort('fid', 'DESC')
       ->range(0, 1)
-- 
GitLab