diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php index acc6b61b5fb27d45b2b9da772e7bdba90f2afbc2..60bc2784e238ec6937373da67ada0ca424fedb0c 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorCronTest.php @@ -25,7 +25,10 @@ public function testCron() { // Create feed and test basic updating on cron. $this->createSampleNodes(); $feed = $this->createFeed(); - $count_query = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->count(); + $count_query = \Drupal::entityQuery('aggregator_item') + ->accessCheck(FALSE) + ->condition('fid', $feed->id()) + ->count(); $this->cronRun(); $this->assertEqual(5, $count_query->execute()); diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php index bafe8d504f2b17a11e63429b0c7f6778c4309ca4..bdd3d5cd00a5de64062e5aa7897a5d0a81fc2a26 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php @@ -80,7 +80,11 @@ public function createFeed($feed_url = NULL, array $edit = []) { // Verify that the creation message contains a link to a feed. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]'); - $fids = \Drupal::entityQuery('aggregator_feed')->condition('title', $edit['title[0][value]'])->condition('url', $edit['url[0][value]'])->execute(); + $fids = \Drupal::entityQuery('aggregator_feed') + ->accessCheck(FALSE) + ->condition('title', $edit['title[0][value]']) + ->condition('url', $edit['url[0][value]']) + ->execute(); $this->assertNotEmpty($fids, 'The feed found in database.'); return Feed::load(array_values($fids)[0]); } @@ -195,7 +199,10 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { $this->clickLink('Update items'); // Ensure we have the right number of items. - $item_ids = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->execute(); + $item_ids = \Drupal::entityQuery('aggregator_item') + ->accessCheck(FALSE) + ->condition('fid', $feed->id()) + ->execute(); $feed->items = array_values($item_ids); if ($expected_count !== NULL) { @@ -224,7 +231,10 @@ public function deleteFeedItems(FeedInterface $feed) { * Expected number of feed items. */ public function updateAndDelete(FeedInterface $feed, $expected_count) { - $count_query = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->count(); + $count_query = \Drupal::entityQuery('aggregator_item') + ->accessCheck(FALSE) + ->condition('fid', $feed->id()) + ->count(); $this->updateFeedItems($feed, $expected_count); $count = $count_query->execute(); $this->assertGreaterThan(0, $count); @@ -245,7 +255,12 @@ public function updateAndDelete(FeedInterface $feed, $expected_count) { * TRUE if feed is unique. */ public function uniqueFeed($feed_name, $feed_url) { - $result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed_name)->condition('url', $feed_url)->count()->execute(); + $result = \Drupal::entityQuery('aggregator_feed') + ->accessCheck(FALSE) + ->condition('title', $feed_name) + ->condition('url', $feed_url) + ->count() + ->execute(); return (1 == $result); } diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php index e31fe47cf6ea315cb6fcbdbb69d6541fe01a2b17..780cdad7d89acabfffaba4d12b1456cc6fc3cc08 100644 --- a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php @@ -48,7 +48,12 @@ public function testDeleteFeed() { $this->assertSession()->statusCodeEquals(404); // Check database for feed. - $result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed1->label())->condition('url', $feed1->getUrl())->count()->execute(); + $result = \Drupal::entityQuery('aggregator_feed') + ->accessCheck(FALSE) + ->condition('title', $feed1->label()) + ->condition('url', $feed1->getUrl()) + ->count() + ->execute(); $this->assertEquals(0, $result, 'Feed not found in database'); } diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php index beafe070462a1c9f263c732fb3cf7c4ddd09c17e..644a31e0a964d4ef2cb0170cfe438c5e5e368b4a 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php @@ -64,7 +64,10 @@ public function testAtomSample() { $this->assertText('Atom-Powered Robots Run Amok'); $this->assertSession()->linkByHrefExists('http://example.org/2003/12/13/atom03'); $this->assertText('Some text.'); - $item_ids = \Drupal::entityQuery('aggregator_item')->condition('link', 'http://example.org/2003/12/13/atom03')->execute(); + $item_ids = \Drupal::entityQuery('aggregator_item') + ->accessCheck(FALSE) + ->condition('link', 'http://example.org/2003/12/13/atom03') + ->execute(); $item = Item::load(array_values($item_ids)[0]); $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $item->getGuid(), 'Atom entry id element is parsed correctly.'); @@ -72,7 +75,10 @@ public function testAtomSample() { $this->assertText('We tried to stop them, but we failed.'); $this->assertSession()->linkByHrefExists('http://example.org/2003/12/14/atom03'); $this->assertText('Some other text.'); - $item_ids = \Drupal::entityQuery('aggregator_item')->condition('link', 'http://example.org/2003/12/14/atom03')->execute(); + $item_ids = \Drupal::entityQuery('aggregator_item') + ->accessCheck(FALSE) + ->condition('link', 'http://example.org/2003/12/14/atom03') + ->execute(); $item = Item::load(array_values($item_ids)[0]); $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-bbbb-80da344efa6a', $item->getGuid(), 'Atom entry id element is parsed correctly.'); } diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php index 2689af9fc0e1b5f514b03d0959ad1bc92ab4ac75..484ef93288a4d1924f49c827817568f3d7ef9ed5 100644 --- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php +++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php @@ -57,7 +57,7 @@ public function openImportForm() { * Submits form filled with invalid fields. */ public function validateImportFormFields() { - $count_query = \Drupal::entityQuery('aggregator_feed')->count(); + $count_query = \Drupal::entityQuery('aggregator_feed')->accessCheck(FALSE)->count(); $before = $count_query->execute(); $edit = []; @@ -85,7 +85,7 @@ public function validateImportFormFields() { * Submits form with invalid, empty, and valid OPML files. */ protected function submitImportForm() { - $count_query = \Drupal::entityQuery('aggregator_feed')->count(); + $count_query = \Drupal::entityQuery('aggregator_feed')->accessCheck(FALSE)->count(); $before = $count_query->execute(); // Attempting to upload invalid XML. diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php index c051d0da4c3c377dcf666479692d914b7a468838..1c43db48202922cc5daa38b81cb04f31aae65974 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php @@ -49,11 +49,17 @@ public function testUpdateFeedItem() { // Verify that the creation message contains a link to a feed. $this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]'); - $fids = \Drupal::entityQuery('aggregator_feed')->condition('url', $edit['url[0][value]'])->execute(); + $fids = \Drupal::entityQuery('aggregator_feed') + ->accessCheck(FALSE) + ->condition('url', $edit['url[0][value]']) + ->execute(); $feed = Feed::load(array_values($fids)[0]); $feed->refreshItems(); - $item_ids = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->execute(); + $item_ids = \Drupal::entityQuery('aggregator_item') + ->accessCheck(FALSE) + ->condition('fid', $feed->id()) + ->execute(); $before = Item::load(array_values($item_ids)[0])->getPostedTime(); // Sleep for 3 second. diff --git a/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php b/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php index 3c360a6a036c3d44a749c1e2b33d8c5113595d00..ca5ea45ba6d5c8101753f51c6d724468fed2f57d 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php @@ -37,7 +37,10 @@ protected function setUp(): void { */ public function testImport() { // Custom block ID must be a number that is not in the database. - $max_id = (int) \Drupal::entityQueryAggregate('block_content')->aggregate('id', 'max')->execute()[0]['id_max']; + $max_id = (int) \Drupal::entityQueryAggregate('block_content') + ->accessCheck(FALSE) + ->aggregate('id', 'max') + ->execute()[0]['id_max']; $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomMachineName(8); $block_array = [ diff --git a/core/modules/block_content/tests/src/Functional/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php index 174231e4edc4da51d95fb9a32c73662209751995..223f3891cfc00bb5575f14bb8e6d4eb57012b1ee 100644 --- a/core/modules/block_content/tests/src/Functional/PageEditTest.php +++ b/core/modules/block_content/tests/src/Functional/PageEditTest.php @@ -37,7 +37,10 @@ public function testPageEdit() { $this->drupalPostForm('block/add/basic', $edit, 'Save'); // Check that the block exists in the database. - $blocks = \Drupal::entityQuery('block_content')->condition('info', $edit['info[0][value]'])->execute(); + $blocks = \Drupal::entityQuery('block_content') + ->accessCheck(FALSE) + ->condition('info', $edit['info[0][value]']) + ->execute(); $block = BlockContent::load(reset($blocks)); $this->assertNotEmpty($block, 'Custom block found in database.'); diff --git a/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php b/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php index 2e38db42ef4d6bd2876c2f753515aac0eb249da1..1b7cc7fd5d094a02257d5615aa1cc729c7115ea7 100644 --- a/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php +++ b/core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php @@ -121,14 +121,20 @@ public function setUp(): void { */ public function testQueriesNotAltered() { // Ensure that queries without all the tags are not altered. - $query = $this->entityTypeManager->getStorage('block_content')->getQuery(); + $query = $this->entityTypeManager->getStorage('block_content') + ->getQuery() + ->accessCheck(FALSE); $this->assertCount(2, $query->execute()); - $query = $this->entityTypeManager->getStorage('block_content')->getQuery(); + $query = $this->entityTypeManager->getStorage('block_content') + ->getQuery() + ->accessCheck(FALSE); $query->addTag('block_content_access'); $this->assertCount(2, $query->execute()); - $query = $this->entityTypeManager->getStorage('block_content')->getQuery(); + $query = $this->entityTypeManager->getStorage('block_content') + ->getQuery() + ->accessCheck(FALSE); $query->addTag('entity_query_block_content'); $this->assertCount(2, $query->execute()); } diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index ec7e19a0287c410796967e1b08927f07e761be09..0d823751b21a4c3ff9e834da00bd62e95a22c1af 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -258,6 +258,7 @@ public function testCommentedTranslationDeletion() { $count_query = \Drupal::entityTypeManager() ->getStorage('comment') ->getQuery() + ->accessCheck(FALSE) ->count(); $before_count = $count_query->execute(); // Post 2 anonymous comments without contact info. diff --git a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php index 2ee4eafe3401c386f3d0cb0d28aa333b0981e55b..dafb973b5f6e4851ce5b07c2083028434aa1d212 100644 --- a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php +++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php @@ -132,6 +132,7 @@ public function testCommentLanguage() { // Check that comment language matches the current content language. $cids = \Drupal::entityQuery('comment') + ->accessCheck(FALSE) ->condition('entity_id', $node->id()) ->condition('entity_type', 'node') ->condition('field_name', 'comment') diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php index 5825ed2863901a1eccc249a2ce3323d8824840b9..76b6bc1f387018bb2c00d40b86fc7940a10eb52c 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationSyncingTest.php @@ -192,6 +192,7 @@ protected function getAllRevisionNames(EntityTestMulRevPub $entity) { return array_map(function ($revision_id) use ($storage) { return $storage->loadRevision($revision_id)->name->value; }, array_keys($storage->getQuery() + ->accessCheck(FALSE) ->allRevisions() ->condition('id', $entity->id()) ->sort('revision_id', 'ASC') diff --git a/core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php b/core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php index 795007042335b6d7a469454b9a07c7fb2d7dbab4..065973a242cd8773f7edc294ae34fd3431e62f7f 100644 --- a/core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php @@ -127,7 +127,7 @@ public function testMultilingual() { protected function assertModerationState($revision_id, $langcode, $expected_state, $expected_workflow = 'editorial') { $moderation_state_storage = $this->entityTypeManager->getStorage('content_moderation_state'); - $query = $moderation_state_storage->getQuery(); + $query = $moderation_state_storage->getQuery()->accessCheck(FALSE); $results = $query->allRevisions() ->condition('content_entity_revision_id', $revision_id) ->condition('langcode', $langcode) diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php index 7f4bcda3f223d956242ab45d62dff683ea4ce813..a4df3849c8f4752447f7ed4a4193515efb3a703a 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php @@ -111,7 +111,7 @@ public function testAutoCreate() { $new_title = $this->randomMachineName(); // Assert referenced node does not exist. - $base_query = \Drupal::entityQuery('node'); + $base_query = \Drupal::entityQuery('node')->accessCheck(FALSE); $base_query ->condition('type', $this->referencedType) ->condition('title', $new_title); @@ -135,6 +135,7 @@ public function testAutoCreate() { // Assert the referenced node is associated with referencing node. $result = \Drupal::entityQuery('node') + ->accessCheck(FALSE) ->condition('type', $this->referencingType) ->execute(); @@ -270,6 +271,7 @@ public function testNoBundles() { // Assert referenced entity was created. $result = \Drupal::entityQuery('entity_test_no_bundle_with_label') + ->accessCheck(FALSE) ->condition('name', $name) ->execute(); $this->assertNotEmpty($result, 'Referenced entity was created.'); @@ -277,6 +279,7 @@ public function testNoBundles() { // Assert the referenced entity is associated with referencing node. $result = \Drupal::entityQuery('node') + ->accessCheck(FALSE) ->condition('type', $this->referencingType) ->execute(); $this->assertCount(1, $result); diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php index dbeb11286adad4e2f2295e0592e08cb9e47c381c..a5d879b4698b110ba355d689922c259da8f3fe0b 100644 --- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php @@ -168,6 +168,7 @@ public function testDeleteField() { // There are 10 entities of this bundle. $found = $storage ->getQuery() + ->accessCheck(FALSE) ->condition('type', $bundle) ->execute(); $this->assertCount(10, $found, 'Correct number of entities found before deleting'); @@ -197,6 +198,7 @@ public function testDeleteField() { // There are 0 entities of this bundle with non-deleted data. $found = $storage ->getQuery() + ->accessCheck(FALSE) ->condition('type', $bundle) ->condition("$field_name.deleted", 0) ->execute(); @@ -206,6 +208,7 @@ public function testDeleteField() { // their values are correct. $found = $storage ->getQuery() + ->accessCheck(FALSE) ->condition('type', $bundle) ->condition("$field_name.deleted", 1) ->sort('id') @@ -334,6 +337,7 @@ public function testPurgeField() { // There are $count deleted entities left. $found = \Drupal::entityQuery('entity_test') + ->accessCheck(FALSE) ->condition('type', $bundle) ->condition($field_name . '.deleted', 1) ->execute(); diff --git a/core/modules/file/tests/src/Functional/FileFieldTestBase.php b/core/modules/file/tests/src/Functional/FileFieldTestBase.php index ce0503f9f99565375be5bb0debc7095b798d7da4..77577d561106a73e6d02146e5c868f175b160284 100644 --- a/core/modules/file/tests/src/Functional/FileFieldTestBase.php +++ b/core/modules/file/tests/src/Functional/FileFieldTestBase.php @@ -74,7 +74,10 @@ public function getTestFile($type_name, $size = NULL) { * Retrieves the fid of the last inserted file. */ public function getLastFileId() { - return (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + return (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; } /** diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php index 0a316463b0cc1ff38dbbe6cb91d7dfa62157069b..6a4e5015782e0b2ddb9474141a78a080d5610806 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php @@ -76,7 +76,10 @@ protected function setUp(): void { $this->phpfile = current($this->drupalGetTestFiles('php')); $this->assertFileExists($this->phpfile->uri); - $this->maxFidBefore = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $this->maxFidBefore = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; /** @var \Drupal\Core\File\FileSystemInterface $file_system */ $file_system = \Drupal::service('file_system'); @@ -99,7 +102,10 @@ protected function setUp(): void { * Tests the _file_save_upload_from_form() function. */ public function testNormal() { - $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $max_fid_after = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; // Verify that a new file was created. $this->assertGreaterThan($this->maxFidBefore, $max_fid_after); $file1 = File::load($max_fid_after); @@ -118,7 +124,10 @@ public function testNormal() { $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, 'Submit'); $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('You WIN!')); - $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $max_fid_after = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; // Check that the correct hooks were called. $this->assertFileHooksCalled(['validate', 'insert']); diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php index fb3b73a10bfc37205800466efcff40a45b794ce4..359c5251fba30cf90ba341f3d7d14263f676d4ac 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php @@ -73,7 +73,10 @@ protected function setUp(): void { $this->phpfile = current($this->drupalGetTestFiles('php')); $this->assertFileExists($this->phpfile->uri); - $this->maxFidBefore = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $this->maxFidBefore = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; // Upload with replace to guarantee there's something there. $edit = [ @@ -95,7 +98,10 @@ protected function setUp(): void { * Test the file_save_upload() function. */ public function testNormal() { - $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $max_fid_after = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; // Verify that a new file was created. $this->assertGreaterThan($this->maxFidBefore, $max_fid_after); $file1 = File::load($max_fid_after); @@ -112,7 +118,10 @@ public function testNormal() { $this->drupalPostForm('file-test/upload', $edit, 'Submit'); $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('You WIN!')); - $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $max_fid_after = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; // Check that the correct hooks were called. $this->assertFileHooksCalled(['validate', 'insert']); @@ -149,7 +158,10 @@ public function testDuplicate() { $image1 = current($this->drupalGetTestFiles('image')); $edit = ['files[file_test_upload]' => \Drupal::service('file_system')->realpath($image1->uri)]; $this->drupalPostForm('file-test/upload', $edit, 'Submit'); - $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $max_fid_after = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; $file1 = File::load($max_fid_after); // Simulate a race condition where two files are uploaded at almost the same @@ -166,7 +178,10 @@ public function testDuplicate() { $message = t('The file %file already exists. Enter a unique file URI.', ['%file' => $file1->getFileUri()]); $this->assertRaw($message); $max_fid_before_duplicate = $max_fid_after; - $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + $max_fid_after = (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; $this->assertEqual($max_fid_before_duplicate, $max_fid_after, 'A new managed file was not created.'); } diff --git a/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php index 944d107d8dcb899cd9a3bc07eb7a2f2043293ccc..f2d788a424cc3664e2fb9b788c203588e0d1cf9d 100644 --- a/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php +++ b/core/modules/file/tests/src/FunctionalJavascript/FileManagedFileElementTest.php @@ -110,7 +110,10 @@ public function testManagedFile() { * Retrieves the fid of the last inserted file. */ protected function getLastFileId() { - return (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + return (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; } } diff --git a/core/modules/file/tests/src/Kernel/SaveTest.php b/core/modules/file/tests/src/Kernel/SaveTest.php index 2d577980e3b17f9b54842a764980fce77aab8cde..c5e523c4094fe8fddc4355f9d9df4e0264c47e00 100644 --- a/core/modules/file/tests/src/Kernel/SaveTest.php +++ b/core/modules/file/tests/src/Kernel/SaveTest.php @@ -77,6 +77,7 @@ public function testFileSave() { $this->assertEqual(t('The file %value already exists. Enter a unique file URI.', ['%value' => $uppercase_file_duplicate->getFileUri()]), $violations[0]->getMessage()); // Ensure that file URI entity queries are case sensitive. $fids = \Drupal::entityQuery('file') + ->accessCheck(FALSE) ->condition('uri', $uppercase_file->getFileUri()) ->execute(); diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php index e48506ffea744340d4c0c54ab6743f3bdfe503a7..9d11008b7c542d3950017c8ae5bce6523e92246d 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -273,6 +273,7 @@ public function testAddOrphanTopic() { // Must remove forum topics to test creating orphan topics. $vid = $this->config('forum.settings')->get('vocabulary'); $tids = \Drupal::entityQuery('taxonomy_term') + ->accessCheck(FALSE) ->condition('vid', $vid) ->execute(); $term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); diff --git a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php index 291e962102b871fecb2342e10bc25a53c437a226..77e75b31a80774ccd18ba32f3deb51cc891285bb 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php +++ b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php @@ -121,7 +121,10 @@ public function uploadNodeImage($image, $field_name, $type, $alt = '') { * Retrieves the fid of the last inserted file. */ protected function getLastFileId() { - return (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; + return (int) \Drupal::entityQueryAggregate('file') + ->accessCheck(FALSE) + ->aggregate('fid', 'max') + ->execute()[0]['fid_max']; } } diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php index 6a57a91ae6742eb30592e66edaff1bb5ad6cb328..c6c940d8b7fd233523074bcabbac60d9ca4694f8 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -355,10 +355,13 @@ protected function setUpFields(EntityInterface $entity, UserInterface $account) * @throws \Drupal\Core\Entity\EntityStorageException */ protected function getData() { - if ($this->entityStorage->getQuery()->count()->execute() < 2) { + if ($this->entityStorage->getQuery()->accessCheck(FALSE)->count()->execute() < 2) { $this->createAnotherEntity('two'); } - $query = $this->entityStorage->getQuery()->sort($this->entity->getEntityType()->getKey('id')); + $query = $this->entityStorage + ->getQuery() + ->accessCheck(FALSE) + ->sort($this->entity->getEntityType()->getKey('id')); return $this->entityStorage->loadMultiple($query->execute()); } diff --git a/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php b/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php index 4adb923590b94493d8a537916f6c5da0cffa0786..2cc221c0db5e423259649ca7cb4964958bcd2f8a 100644 --- a/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php @@ -169,7 +169,7 @@ public function testQueryCondition() { $expected_query = $case[1]; $filter = Filter::createFromQueryParameter($parameter, $resource_type, $this->fieldResolver); - $query = $this->nodeStorage->getQuery(); + $query = $this->nodeStorage->getQuery()->accessCheck(FALSE); // Get the query condition parsed from the input. $condition = $filter->queryCondition($query); @@ -192,7 +192,7 @@ public function testQueryCondition() { */ protected function queryConditionData() { // ((RED or CIRCLE) or (YELLOW and SQUARE)) - $query = $this->nodeStorage->getQuery(); + $query = $this->nodeStorage->getQuery()->accessCheck(FALSE); $or_group = $query->orConditionGroup(); diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php index 856a4a83a2a87d842327c965c37e78a1cc1f37ed..14efc24d13563adfb1e8356ea855f2372b3a0afe 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php @@ -342,6 +342,7 @@ protected function assertNodeRevisionContent($revision_id, array $content) { */ protected function assertBlockRevisionCountByTitle($block_title, $expected_revision_count) { $actual_revision_count = $this->blockStorage->getQuery() + ->accessCheck(FALSE) ->condition('info', $block_title) ->allRevisions() ->count() diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php index 24e7f3ece564ef5afb8372398635a2a8ef5d8e58..dbf68d6179c17127459d5cbd97bef894fe6a0208 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php @@ -97,7 +97,11 @@ protected function assertSaveLayout() { * Gets the latest block entity id. */ protected function getLatestBlockEntityId() { - $block_ids = \Drupal::entityQuery('block_content')->sort('id', 'DESC')->range(0, 1)->execute(); + $block_ids = \Drupal::entityQuery('block_content') + ->accessCheck(FALSE) + ->sort('id', 'DESC') + ->range(0, 1) + ->execute(); $block_id = array_pop($block_ids); $this->assertNotEmpty($this->blockStorage->load($block_id)); return $block_id; diff --git a/core/modules/media/tests/src/Functional/MediaRevisionTest.php b/core/modules/media/tests/src/Functional/MediaRevisionTest.php index 184a1b284c4c414f7276ebd3dc65cbab25a388ef..c08b392a63bf6cece177b87692f7f8bb9baf9861 100644 --- a/core/modules/media/tests/src/Functional/MediaRevisionTest.php +++ b/core/modules/media/tests/src/Functional/MediaRevisionTest.php @@ -198,6 +198,7 @@ protected function assertRevisionCount(EntityInterface $entity, $expected_revisi ->get('entity_type.manager') ->getStorage($entity_type->id()) ->getQuery() + ->accessCheck(FALSE) ->count() ->allRevisions() ->condition($entity_type->getKey('id'), $entity->id()) diff --git a/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php b/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php index 6155a1acbde95667a0960133a4eb910635bf5e1a..99953f796473c891414cb73235e8bebb0726e077 100644 --- a/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php +++ b/core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php @@ -67,6 +67,7 @@ public function testMediaWithOnlyOneMediaType() { $media_id = $this->container->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->execute(); $media_id = reset($media_id); /** @var \Drupal\media\MediaInterface $media */ @@ -139,7 +140,7 @@ public function testMediaWithOnlyOneMediaType() { $page->clickLink('Delete'); $assert_session->pageTextContains('This action cannot be undone'); $page->pressButton('Delete'); - $media_id = \Drupal::entityQuery('media')->execute(); + $media_id = \Drupal::entityQuery('media')->accessCheck(FALSE)->execute(); $this->assertEmpty($media_id); } @@ -446,6 +447,7 @@ public function testMediaCreateRedirect() { $media_id = $this->container->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->execute(); $media_id = reset($media_id); $assert_session->addressEquals("media/$media_id/edit"); diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php index adc4dd1284d2ca25cba55a07f0de333255b193a2..ce548a0a5f361af19caf8908178eaaae214f123d 100644 --- a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php @@ -91,6 +91,7 @@ public function testMediaDisplay() { ->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->sort('mid', 'DESC') ->execute(); $image_media_id = reset($image_media_id); diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php index e3293b591ead2f3d2eb6945276c4258b8754e2a4..40c69186007e1bdd6cd61f31903cfd2e4cdc2958 100644 --- a/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php @@ -124,6 +124,7 @@ protected function audioTest() { ->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->sort('mid', 'DESC') ->execute(); $audio_media_id = reset($audio_media_id); @@ -209,6 +210,7 @@ protected function imageTest() { ->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->sort('mid', 'DESC') ->execute(); $image_media_id = reset($image_media_id); @@ -308,6 +310,7 @@ protected function documentTest() { ->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->sort('mid', 'DESC') ->execute(); $file_media_id = reset($file_media_id); @@ -395,6 +398,7 @@ protected function remoteVideoTest() { ->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->sort('mid', 'DESC') ->execute(); $remote_video_media_id = reset($remote_video_media_id); @@ -491,6 +495,7 @@ protected function videoTest() { ->get('entity_type.manager') ->getStorage('media') ->getQuery() + ->accessCheck(FALSE) ->sort('mid', 'DESC') ->execute(); $video_media_id = reset($video_media_id); diff --git a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php index 26cc7dcd3f9cffcfe0e14eb5560ead077a37c3de..eb648b7cedb632f8170d9cfe1305f3dd236e0e1b 100644 --- a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php +++ b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php @@ -289,7 +289,7 @@ protected function assertNodeDoesNotExist($title) { * @return bool */ protected function nodeExists($title) { - $query = \Drupal::entityQuery('node'); + $query = \Drupal::entityQuery('node')->accessCheck(FALSE); $result = $query ->condition('title', $title) ->range(0, 1) diff --git a/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php b/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php index 0c27bf29919477c694a3b69e4a45a81a0a590c5d..04d45b8c04d6d81ace140faa148703fa5cead50c 100644 --- a/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php +++ b/core/modules/migrate/tests/src/Kernel/TrackChangesTest.php @@ -182,7 +182,7 @@ protected function assertTermDoesNotExist($property, $value) { */ protected function termExists($property, $value) { $property = $property === 'description' ? 'description__value' : $property; - $query = \Drupal::entityQuery('taxonomy_term'); + $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE); $result = $query ->condition($property, $value) ->range(0, 1) diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php index 2cca7136bd87c19df1040fe4c14b021689d4fce3..6565ec7c4dc1cb36809b8cf3175223d803ac2e05 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeTestBase.php @@ -253,7 +253,7 @@ protected function assertUpgrade(array $entity_counts) { // Assert the correct number of entities exists. $actual_entity_counts = []; foreach ($entity_definitions as $entity_type) { - $actual_entity_counts[$entity_type] = (int) \Drupal::entityQuery($entity_type)->count()->execute(); + $actual_entity_counts[$entity_type] = (int) \Drupal::entityQuery($entity_type)->accessCheck(FALSE)->count()->execute(); } $this->assertSame($entity_counts, $actual_entity_counts); diff --git a/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php b/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php index 46f4a5e1026fbee32d8c871a56d27a9350a6c2a7..feb40c60e1f83df4c754a0391ad12a03b65d7600 100644 --- a/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php +++ b/core/modules/node/tests/node_access_test_auto_bubbling/src/Controller/NodeAccessTestAutoBubblingController.php @@ -19,6 +19,7 @@ class NodeAccessTestAutoBubblingController extends ControllerBase implements Con */ public function latest() { $nids = $this->entityTypeManager()->getStorage('node')->getQuery() + ->accessCheck(TRUE) ->condition('status', NodeInterface::PUBLISHED) ->sort('created', 'DESC') ->range(0, 3) diff --git a/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php b/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php index ad9324244cbcc5f52c3597fb9c33f439803c5254..a54a93ba9d407c853a87de5725b036fcc104453b 100644 --- a/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php +++ b/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php @@ -92,6 +92,7 @@ public function testNodeQueryAlterWithRevisions() { try { $query = \Drupal::entityTypeManager()->getStorage('node')->getQuery(); $result = $query + ->accessCheck(TRUE) ->allRevisions() ->execute(); diff --git a/core/modules/node/tests/src/Functional/NodeSaveTest.php b/core/modules/node/tests/src/Functional/NodeSaveTest.php index 69c8563a3f47158f01b396fcb62ce32def15053f..7ea6f4054795e7f6b8c82e7208b5790ae1e3daeb 100644 --- a/core/modules/node/tests/src/Functional/NodeSaveTest.php +++ b/core/modules/node/tests/src/Functional/NodeSaveTest.php @@ -50,6 +50,7 @@ protected function setUp(): void { public function testImport() { // Node ID must be a number that is not in the database. $nids = \Drupal::entityTypeManager()->getStorage('node')->getQuery() + ->accessCheck(FALSE) ->sort('nid', 'DESC') ->range(0, 1) ->execute(); diff --git a/core/modules/system/tests/modules/cache_test/src/Controller/CacheTestController.php b/core/modules/system/tests/modules/cache_test/src/Controller/CacheTestController.php index b773d5bb5ae0fda611d2890c021b0e9c5a988963..9ebc6f3188f4df10f40b32188c4c0366fda87800 100644 --- a/core/modules/system/tests/modules/cache_test/src/Controller/CacheTestController.php +++ b/core/modules/system/tests/modules/cache_test/src/Controller/CacheTestController.php @@ -32,7 +32,7 @@ public function urlBubbling() { */ public function bundleTags($entity_type_id, $bundle) { $storage = \Drupal::entityTypeManager()->getStorage($entity_type_id); - $entity_ids = $storage->getQuery()->condition('type', $bundle)->execute(); + $entity_ids = $storage->getQuery()->accessCheck(TRUE)->condition('type', $bundle)->execute(); $page = []; $entities = $storage->loadMultiple($entity_ids); diff --git a/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php b/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php index e9f0f8a689a4babbf8c5d4a35a42cc6a8ec7ec05..3c56037291490894b540755855948921548acbba 100644 --- a/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php +++ b/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php @@ -42,6 +42,7 @@ public function listReferencingEntities($entity_reference_field_name, $reference } $query = $this->entityTypeManager()->getStorage('entity_test')->getQuery() + ->accessCheck(TRUE) ->condition($entity_reference_field_name . '.target_id', $referenced_entity_id); $entities = $this->entityTypeManager() ->getStorage('entity_test') @@ -62,7 +63,7 @@ public function listReferencingEntities($entity_reference_field_name, $reference */ public function listEntitiesAlphabetically($entity_type_id) { $entity_type_definition = $this->entityTypeManager()->getDefinition($entity_type_id); - $query = $this->entityTypeManager()->getStorage($entity_type_id)->getQuery(); + $query = $this->entityTypeManager()->getStorage($entity_type_id)->getQuery()->accessCheck(TRUE); // Sort by label field, if any. if ($label_field = $entity_type_definition->getKey('label')) { diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index 754b3b18ac21f7e64f6e6181bd1892f69488e587..2897fcee64604d8bd973d7102955b45e5fdd6d8f 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -359,7 +359,7 @@ protected function assertHelp($module, $name) { protected function preUninstallForum() { // There only should be a 'General discussion' term in the 'forums' // vocabulary, but just delete any terms there in case the name changes. - $query = \Drupal::entityQuery('taxonomy_term'); + $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE); $query->condition('vid', 'forums'); $ids = $query->execute(); $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); diff --git a/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php b/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php index 03a71dd98442f8312289427f4866a526e176fa2b..52c9da687c553ac94f4c7eb14bf16e6289eec9c4 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermParentsTest.php @@ -121,6 +121,7 @@ protected function submitAddTermForm($name) { $result = $this->termStorage ->getQuery() + ->accessCheck(FALSE) ->condition('name', $name) ->execute(); /* @var \Drupal\taxonomy\TermInterface $term_1 */ diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php index 58678d6ed48a4f5637c1584c79c599e2860d34a1..f6cdca485e7fd4cdd184908b82641eaac246f66e 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -97,6 +97,7 @@ public function testTranslationUI() { // Make sure that no row was inserted for taxonomy vocabularies which do // not have translations enabled. $tids = \Drupal::entityQueryAggregate('taxonomy_term') + ->accessCheck(FALSE) ->aggregate('tid', 'COUNT') ->condition('vid', $this->bundle, '<>') ->groupBy('tid') diff --git a/core/modules/taxonomy/tests/src/Kernel/TaxonomyQueryAlterTest.php b/core/modules/taxonomy/tests/src/Kernel/TaxonomyQueryAlterTest.php index 0743adb63795b9897f03c8e0a8062928d131c67a..544194356a3d38ae3639c446748f468e00991ce1 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TaxonomyQueryAlterTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TaxonomyQueryAlterTest.php @@ -96,7 +96,7 @@ public function testTaxonomyQueryAlter() { $this->assertQueryTagTestResult(1, 1); $this->setupQueryTagTestHooks(); - $query = \Drupal::entityQuery('taxonomy_term'); + $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE); $query->addTag('taxonomy_term_access'); $result = $query->execute(); // All term IDs were retrieved. @@ -105,7 +105,7 @@ public function testTaxonomyQueryAlter() { $this->assertQueryTagTestResult(1, 1); $this->setupQueryTagTestHooks(); - $query = \Drupal::entityQuery('taxonomy_term'); + $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE); $query->addTag('term_access'); $result = $query->execute(); // All term IDs were retrieved. diff --git a/core/modules/taxonomy/tests/src/Kernel/TermEntityQueryTest.php b/core/modules/taxonomy/tests/src/Kernel/TermEntityQueryTest.php index afe93fe12d0bc3f5e62f6d6a71497373eccd7be6..886df937ac45f760866855bb4927ffff4c510ec5 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermEntityQueryTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermEntityQueryTest.php @@ -37,7 +37,7 @@ public function testTermEntityQuery() { $term = $this->createTerm($vocabulary); $terms[$term->id()] = $term; } - $result = \Drupal::entityQuery('taxonomy_term')->execute(); + $result = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE)->execute(); sort($result); $this->assertEquals(array_keys($terms), $result); $tid = reset($result); @@ -58,6 +58,7 @@ public function testTermEntityQuery() { } $result = \Drupal::entityQuery('taxonomy_term') + ->accessCheck(FALSE) ->condition('vid', $vocabulary2->id()) ->execute(); sort($result); diff --git a/core/modules/taxonomy/tests/src/Kernel/VocabularyCrudTest.php b/core/modules/taxonomy/tests/src/Kernel/VocabularyCrudTest.php index 1078e92cd3440732c13a5678a1ff6717d534c266..471a0dc5a7cfa212288e796ab8b0b5349b7218a1 100644 --- a/core/modules/taxonomy/tests/src/Kernel/VocabularyCrudTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/VocabularyCrudTest.php @@ -44,7 +44,7 @@ protected function setUp(): void { */ public function testTaxonomyVocabularyDeleteWithTerms() { $vocabulary = $this->createVocabulary(); - $query = \Drupal::entityQuery('taxonomy_term')->count(); + $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE)->count(); // Assert that there are no terms left. $this->assertEquals(0, $query->execute()); diff --git a/core/modules/user/tests/src/Kernel/UserInstallTest.php b/core/modules/user/tests/src/Kernel/UserInstallTest.php index 1ab0df44acb03cb96f8d2205e485d080023a3371..e93980cf34aa719d79c3630d40f22eb2c7de50b1 100644 --- a/core/modules/user/tests/src/Kernel/UserInstallTest.php +++ b/core/modules/user/tests/src/Kernel/UserInstallTest.php @@ -32,7 +32,7 @@ protected function setUp(): void { * Test that the initial users have correct values. */ public function testUserInstall() { - $user_ids = \Drupal::entityQuery('user')->sort('uid')->execute(); + $user_ids = \Drupal::entityQuery('user')->sort('uid')->accessCheck(FALSE)->execute(); $users = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple($user_ids); $anon = $users[0]; $admin = $users[1]; diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index 155db90990a5dd20852a6f81b5a2c3747a5aa4f7..7bc995139f12ab2678c5980514ca0638413fb7d2 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -214,6 +214,7 @@ public function testDefaultMenuTabRegression() { $this->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, 'Save'); $menu_items = \Drupal::entityTypeManager()->getStorage('menu_link_content')->getQuery() + ->accessCheck(FALSE) ->sort('id', 'DESC') ->pager(1) ->execute(); diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php index 9d12b1f08209bc4a1d2369ee01b651f688a6e514..e9ba0eb350cf13d304ce8454a1f01b1c77353005 100644 --- a/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php +++ b/core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php @@ -487,14 +487,14 @@ public function testEntityQueryWithoutConditions() { $node->title->value = 'stage - 2 - r3 - published'; $node->save(); - $query = $this->entityTypeManager->getStorage('node')->getQuery(); + $query = $this->entityTypeManager->getStorage('node')->getQuery()->accessCheck(FALSE); $query->sort('nid'); $query->pager(1); $result = $query->execute(); $this->assertSame([1 => '1'], $result); - $query = $this->entityTypeManager->getStorage('node')->getQuery(); + $query = $this->entityTypeManager->getStorage('node')->getQuery()->accessCheck(FALSE); $query->sort('nid', 'DESC'); $query->pager(10); $result = $query->execute(); @@ -546,7 +546,7 @@ public function testEntityQueryRelationship() { $entity_test->save(); // Make sure that we're requesting the default revision. - $query = $this->entityTypeManager->getStorage('node')->getQuery(); + $query = $this->entityTypeManager->getStorage('node')->getQuery()->accessCheck(FALSE); $query->currentRevision(); $query @@ -722,6 +722,7 @@ public function testExecuteInWorkspaceContext() { $this->assertEquals('live node 1', $live_node->title->value); $result = $storage->getQuery() + ->accessCheck(FALSE) ->condition('title', 'live node 1') ->execute(); $this->assertEquals([$live_node->getRevisionId() => $node->id()], $result); @@ -734,6 +735,7 @@ public function testExecuteInWorkspaceContext() { $this->assertEquals('stage node 1', $stage_node->title->value); $result = $storage->getQuery() + ->accessCheck(FALSE) ->condition('title', 'stage node 1') ->execute(); $this->assertEquals([$stage_node->getRevisionId() => $stage_node->id()], $result); @@ -914,20 +916,20 @@ protected function assertEntityQuery(array $expected_values, $entity_type_id) { }); // Check entity query counts. - $result = (int) $storage->getQuery()->count()->execute(); + $result = (int) $storage->getQuery()->accessCheck(FALSE)->count()->execute(); $this->assertSame(count($expected_default_revisions), $result); $result = (int) $storage->getAggregateQuery()->count()->execute(); $this->assertSame(count($expected_default_revisions), $result); // Check entity queries with no conditions. - $result = $storage->getQuery()->execute(); + $result = $storage->getQuery()->accessCheck(FALSE)->execute(); $expected_result = array_combine(array_column($expected_default_revisions, $revision_key), array_column($expected_default_revisions, $id_key)); $this->assertEquals($expected_result, $result); // Check querying each revision individually. foreach ($expected_values as $expected_value) { - $query = $storage->getQuery(); + $query = $storage->getQuery()->accessCheck(FALSE); $query ->condition($entity_keys['id'], $expected_value[$id_key]) ->condition($entity_keys['label'], $expected_value[$label_key]) diff --git a/core/profiles/demo_umami/modules/demo_umami_content/tests/src/Functional/UninstallDefaultContentTest.php b/core/profiles/demo_umami/modules/demo_umami_content/tests/src/Functional/UninstallDefaultContentTest.php index 3b97c5c33c290c79d13cd66062819f745682d359..205575be3a9c7e468ad2a294e5e33aa9b98ba1d3 100644 --- a/core/profiles/demo_umami/modules/demo_umami_content/tests/src/Functional/UninstallDefaultContentTest.php +++ b/core/profiles/demo_umami/modules/demo_umami_content/tests/src/Functional/UninstallDefaultContentTest.php @@ -32,6 +32,7 @@ public function testReinstall() { $this->assertRecipesImported($node_storage); $count = $node_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', 'article') ->count() ->execute(); @@ -47,6 +48,7 @@ public function testReinstall() { // Assert the removal of blocks on uninstall. foreach ($this->expectedBlocks() as $block_info) { $count = $block_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', $block_info['type']) ->count() ->execute(); @@ -57,12 +59,14 @@ public function testReinstall() { // Assert the removal of nodes on uninstall. $count = $node_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', 'article') ->count() ->execute(); $this->assertEquals(0, $count); $count = $node_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', 'recipe') ->count() ->execute(); @@ -83,6 +87,7 @@ public function testReinstall() { */ protected function assertRecipesImported(EntityStorageInterface $node_storage) { $count = $node_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', 'recipe') ->count() ->execute(); @@ -101,6 +106,7 @@ protected function assertRecipesImported(EntityStorageInterface $node_storage) { */ protected function assertArticlesImported(EntityStorageInterface $node_storage) { $count = $node_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', 'article') ->count() ->execute(); @@ -134,6 +140,7 @@ protected function assertImportedCustomBlock(EntityStorageInterface $block_stora // Verify that the block can be loaded. $count = $block_storage->getQuery() + ->accessCheck(FALSE) ->condition('type', $block_info['type']) ->count() ->execute(); diff --git a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php index 90d77e884971768bb75bf267279039cbe5afc7dc..d287572c3c9dd541795c8d3e63f67e5dfae5f5fc 100644 --- a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php +++ b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php @@ -96,6 +96,7 @@ protected function assertDefaultConfig(StorageInterface $default_config_storage, public function testUser() { $password = $this->rootUser->pass_raw; $ids = \Drupal::entityQuery('user') + ->accessCheck(FALSE) ->condition('roles', ['author', 'editor'], 'IN') ->execute(); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php index 9904c9cc671be13079944719355d622e3cb9421a..27c8d1e09f78a8c1bcc9fc3a3ca5ea20d3debaa3 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php @@ -165,17 +165,17 @@ public function testChanged() { // At this point the changed time of the original language (en) is newer // than the changed time of the German translation. Now test that entity // queries work as expected. - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_en)->execute(); $this->assertEqual($entity->id(), reset($ids), 'Entity query can access changed time of original language.'); - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_en, '=', 'en')->execute(); $this->assertEqual($entity->id(), reset($ids), 'Entity query can access changed time of original language by setting the original language as condition.'); - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_de, '=', 'en')->execute(); $this->assertEmpty( @@ -183,12 +183,12 @@ public function testChanged() { 'There\'s no original entity stored having the changed time of the German translation.' ); - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_en)->condition('default_langcode', '1')->execute(); $this->assertEqual($entity->id(), reset($ids), 'Entity query can access changed time of default language.'); - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_de)->condition('default_langcode', '1')->execute(); $this->assertEmpty( @@ -196,12 +196,12 @@ public function testChanged() { 'There\'s no entity stored using the default language having the changed time of the German translation.' ); - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_de)->execute(); $this->assertEqual($entity->id(), reset($ids), 'Entity query can access changed time of the German translation.'); - $query = $this->mulChangedStorage->getQuery(); + $query = $this->mulChangedStorage->getQuery()->accessCheck(FALSE); $ids = $query->condition('changed', $changed_de, '=', 'de')->execute(); $this->assertEqual($entity->id(), reset($ids), 'Entity query can access changed time of the German translation.'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php index 92dfd589dbb6ed189505f1c406bcdb5c9a8330b1..be73cf8ecd5db793e083fdeda29a8fa81aed2179 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php @@ -101,6 +101,7 @@ public function testMulNonRevisionableField() { 1 => 1, ]; $revision_ids = $this->mulRev->getQuery() + ->accessCheck(FALSE) ->allRevisions() ->sort('revision_id', 'DESC') ->execute(); @@ -111,6 +112,7 @@ public function testMulNonRevisionableField() { 1 => 1, ]; $non_rev_field_revision_ids = $this->mulRev->getQuery() + ->accessCheck(FALSE) ->allRevisions() ->condition('non_rev_field', 'Huron') ->sort('revision_id', 'DESC') @@ -160,6 +162,7 @@ public function testNonRevisionableField() { 1 => 1, ]; $revision_ids = $this->rev->getQuery() + ->accessCheck(FALSE) ->allRevisions() ->sort('revision_id', 'DESC') ->execute(); @@ -170,6 +173,7 @@ public function testNonRevisionableField() { 1 => 1, ]; $non_rev_field_revision_ids = $this->rev->getQuery() + ->accessCheck(FALSE) ->allRevisions() ->condition('non_rev_field', 'Superior') ->sort('revision_id', 'DESC') diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php index 83baf006f0852f3d3329082428fbff4c120b15dd..3b9dcf2af17aba5f204ef936aa92a1ae83cd2508 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php @@ -30,10 +30,10 @@ class ContentEntityNullStorageTest extends KernelTestBase { * @see \Drupal\Core\Entity\Query\Null\Query */ public function testEntityQuery() { - $this->assertSame(0, \Drupal::entityQuery('contact_message')->count()->execute(), 'Counting a null storage returns 0.'); - $this->assertSame([], \Drupal::entityQuery('contact_message')->execute(), 'Querying a null storage returns an empty array.'); - $this->assertSame([], \Drupal::entityQuery('contact_message')->condition('contact_form', 'test')->execute(), 'Querying a null storage returns an empty array and conditions are ignored.'); - $this->assertSame([], \Drupal::entityQueryAggregate('contact_message')->aggregate('name', 'AVG')->execute(), 'Aggregate querying a null storage returns an empty array'); + $this->assertSame(0, \Drupal::entityQuery('contact_message')->accessCheck(FALSE)->count()->execute(), 'Counting a null storage returns 0.'); + $this->assertSame([], \Drupal::entityQuery('contact_message')->accessCheck(FALSE)->execute(), 'Querying a null storage returns an empty array.'); + $this->assertSame([], \Drupal::entityQuery('contact_message')->accessCheck(FALSE)->condition('contact_form', 'test')->execute(), 'Querying a null storage returns an empty array and conditions are ignored.'); + $this->assertSame([], \Drupal::entityQueryAggregate('contact_message')->accessCheck(FALSE)->aggregate('name', 'AVG')->execute(), 'Aggregate querying a null storage returns an empty array'); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php index 3968696745c2ff6b24bc94cf256b9da443784ff4..6f0ac63ac6b4c18d915bf76ac6a10408656efdf8 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php @@ -554,7 +554,10 @@ public function testEntityRollback() { } // Check that the block does not exist in the database. - $ids = \Drupal::entityQuery('entity_test')->condition('name', 'fail_insert')->execute(); + $ids = \Drupal::entityQuery('entity_test') + ->accessCheck(FALSE) + ->condition('name', 'fail_insert') + ->execute(); $this->assertEmpty($ids); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php index 016117407116863e4bf595b6a3ec7cdb23619a8d..2c88dccefc521d1b2ac02e1829213f3fb4e7a795 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php @@ -114,78 +114,92 @@ public function testQuery() { // This returns the 0th entity as that's the only one pointing to the 0th // account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("user_id.entity.name", $this->accounts[0]->getAccountName()) ->execute(); $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("user_id.entity.name", $this->accounts[0]->getAccountName(), '<>') ->execute(); $this->assertResults([1, 2]); // This returns all three entities because all of them point to an // account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->exists("user_id.entity.name") ->execute(); $this->assertResults([0, 1, 2]); // This returns no entities because all of them point to an account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->notExists("user_id.entity.name") ->execute(); $this->assertCount(0, $this->queryResults); // This returns the 0th entity as that's only one pointing to the 0th // term (test without specifying the field column). $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("$this->fieldName.entity.name", $this->terms[0]->name->value) ->execute(); $this->assertResults([0]); // This returns the 0th entity as that's only one pointing to the 0th // term (test with specifying the column name). $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("$this->fieldName.target_id.entity.name", $this->terms[0]->name->value) ->execute(); $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st term. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("$this->fieldName.entity.name", $this->terms[0]->name->value, '<>') ->execute(); $this->assertResults([1, 2]); // This returns the 0th entity as that's only one pointing to the 0th // account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("user_id.entity:user.name", $this->accounts[0]->getAccountName()) ->execute(); $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("user_id.entity:user.name", $this->accounts[0]->getAccountName(), '<>') ->execute(); $this->assertResults([1, 2]); // This returns all three entities because all of them point to an // account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->exists("user_id.entity:user.name") ->execute(); $this->assertResults([0, 1, 2]); // This returns no entities because all of them point to an account. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->notExists("user_id.entity:user.name") ->execute(); $this->assertCount(0, $this->queryResults); // This returns the 0th entity as that's only one pointing to the 0th // term (test without specifying the field column). $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value) ->execute(); $this->assertResults([0]); // This returns the 0th entity as that's only one pointing to the 0th // term (test with specifying the column name). $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("$this->fieldName.target_id.entity:taxonomy_term.name", $this->terms[0]->name->value) ->execute(); $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st term. $this->queryResults = $storage->getQuery() + ->accessCheck(FALSE) ->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value, '<>') ->execute(); $this->assertResults([1, 2]); @@ -200,6 +214,7 @@ public function testInvalidSpecifier() { ->get('entity_type.manager') ->getStorage('taxonomy_term') ->getQuery() + ->accessCheck(FALSE) ->condition('langcode.language.foo', 'bar') ->execute(); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php index ca138f86306f0a56755f2ffee4cf9fd8ec0840d5..7b9ce50d2015f79969f635a340928ae9d4aa0553 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php @@ -162,6 +162,7 @@ public function testEntityQuery() { $figures = $this->figures; $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->exists($greetings, 'tr') ->condition("$figures.color", 'red') ->sort('id') @@ -172,6 +173,7 @@ public function testEntityQuery() { $query = $this->storage ->getQuery('OR') + ->accessCheck(FALSE) ->exists($greetings, 'tr') ->condition("$figures.color", 'red') ->sort('id'); @@ -185,6 +187,7 @@ public function testEntityQuery() { // Test cloning of query conditions. $query = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.color", 'red') ->sort('id'); $cloned_query = clone $query; @@ -197,7 +200,7 @@ public function testEntityQuery() { $this->queryResults = $cloned_query->execute(); $this->assertResult(); - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); $group = $query->orConditionGroup() ->exists($greetings, 'tr') ->condition("$figures.color", 'red'); @@ -212,6 +215,7 @@ public function testEntityQuery() { // No figure has both the colors blue and red at the same time. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.color", 'blue') ->condition("$figures.color", 'red') ->sort('id') @@ -219,7 +223,7 @@ public function testEntityQuery() { $this->assertResult(); // But an entity might have a red and a blue figure both. - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); $group_blue = $query->andConditionGroup()->condition("$figures.color", 'blue'); $group_red = $query->andConditionGroup()->condition("$figures.color", 'red'); $this->queryResults = $query @@ -231,7 +235,7 @@ public function testEntityQuery() { $this->assertResult(3, 7, 11, 15); // Do the same test but with IN operator. - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); $group_blue = $query->andConditionGroup()->condition("$figures.color", ['blue'], 'IN'); $group_red = $query->andConditionGroup()->condition("$figures.color", ['red'], 'IN'); $this->queryResults = $query @@ -245,6 +249,7 @@ public function testEntityQuery() { // An entity might have either red or blue figure. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.color", ['blue', 'red'], 'IN') ->sort('id') ->execute(); @@ -253,6 +258,7 @@ public function testEntityQuery() { $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->exists("$figures.color") ->notExists("$greetings.value") ->sort('id') @@ -263,6 +269,7 @@ public function testEntityQuery() { // word but allows us to test revisions and string operations. $ids = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'merhaba') ->sort('id') ->execute(); @@ -278,6 +285,7 @@ public function testEntityQuery() { // Test querying all revisions with a condition on the revision ID field. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('revision_id', $first_entity->getRevisionId()) ->allRevisions() ->execute(); @@ -286,12 +294,14 @@ public function testEntityQuery() { // We changed the entity names, so the current revision should not match. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('name.value', $old_name) ->execute(); $this->assertResult(); // Only if all revisions are queried, we find the old revision. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('name.value', $old_name) ->allRevisions() ->sort('revision_id') @@ -300,11 +310,13 @@ public function testEntityQuery() { // When querying current revisions, this string is no longer found. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'merhaba') ->execute(); $this->assertResult(); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'merhaba') ->allRevisions() ->sort('revision_id') @@ -313,6 +325,7 @@ public function testEntityQuery() { $this->assertRevisionResult([4, 5, 6, 7, 12, 13, 14, 15], [4, 5, 6, 7, 12, 13, 14, 15]); $results = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'siema', 'CONTAINS') ->sort('id') ->execute(); @@ -322,6 +335,7 @@ public function testEntityQuery() { $this->assertSame($assert, $results); $results = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'siema', 'STARTS_WITH') ->sort('revision_id') ->execute(); @@ -330,6 +344,7 @@ public function testEntityQuery() { $this->assertSame(array_slice($assert, 4, 8, TRUE), $results); $results = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'a', 'ENDS_WITH') ->sort('revision_id') ->execute(); @@ -338,6 +353,7 @@ public function testEntityQuery() { $this->assertSame(array_slice($assert, 4, 8, TRUE), $results); $results = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$greetings.value", 'a', 'ENDS_WITH') ->allRevisions() ->sort('id') @@ -351,6 +367,7 @@ public function testEntityQuery() { // the correct results. $results = $this->storage ->getQuery() + ->accessCheck(FALSE) ->latestRevision() ->sort('id') ->sort('revision_id') @@ -370,16 +387,19 @@ public function testSort() { // Order up and down on a number. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->sort('id') ->execute(); $this->assertResult(range(1, 15)); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->sort('id', 'DESC') ->execute(); $this->assertResult(range(15, 1)); $query = $this->storage ->getQuery() + ->accessCheck(FALSE) ->sort("$figures.color") ->sort("$greetings.format") ->sort('id'); @@ -431,6 +451,7 @@ public function testSort() { \Drupal::getContainer()->get('request_stack')->push($request); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->sort("$figures.color") ->sort("$greetings.format") ->sort('id') @@ -441,6 +462,7 @@ public function testSort() { // Now test the reversed order. $query = $this->storage ->getQuery() + ->accessCheck(FALSE) ->sort("$figures.color", 'DESC') ->sort("$greetings.format", 'DESC') ->sort('id', 'DESC'); @@ -471,6 +493,7 @@ public function testTableSort() { $this->queryResults = array_values($this->storage ->getQuery() + ->accessCheck(FALSE) ->tableSort($header) ->execute()); $this->assertBundleOrder('asc'); @@ -486,6 +509,7 @@ public function testTableSort() { ]; $this->queryResults = array_values($this->storage ->getQuery() + ->accessCheck(FALSE) ->tableSort($header) ->execute()); $this->assertBundleOrder('desc'); @@ -497,6 +521,7 @@ public function testTableSort() { \Drupal::getContainer()->get('request_stack')->push($request); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->tableSort($header) ->execute(); $this->assertResult(range(15, 1)); @@ -534,6 +559,7 @@ public function testCount() { $count = $this->container->get('entity_type.manager') ->getStorage('entity_test') ->getQuery() + ->accessCheck(FALSE) ->exists("$field_name.color") ->count() ->execute(); @@ -546,7 +572,7 @@ public function testCount() { public function testNestedConditionGroups() { // Query for all entities of the first bundle that have either a red // triangle as a figure or the Turkish greeting as a greeting. - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); $first_and = $query->andConditionGroup() ->condition($this->figures . '.color', 'red') @@ -574,7 +600,7 @@ public function testNestedConditionGroups() { public function testConditionCount() { // Query for all entities of the first bundle that // have red as a color AND are triangle shaped. - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); // Add an AND condition group with 2 conditions in it. $and_condition_group = $query->andConditionGroup() @@ -601,6 +627,7 @@ public function testDelta() { // Test numeric delta value in field condition. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.0.color", 'red') ->sort('id') ->execute(); @@ -609,6 +636,7 @@ public function testDelta() { $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.1.color", 'red') ->sort('id') ->execute(); @@ -616,7 +644,7 @@ public function testDelta() { $this->assertResult(); // Test on two different deltas. - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); $or = $query->andConditionGroup() ->condition("$figures.0.color", 'red') ->condition("$figures.1.color", 'blue'); @@ -629,6 +657,7 @@ public function testDelta() { // Test the delta range condition. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.%delta.color", ['blue', 'red'], 'IN') ->condition("$figures.%delta", [0, 1], 'IN') ->sort('id') @@ -639,6 +668,7 @@ public function testDelta() { // Test the delta range condition without conditions on the value. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("$figures.%delta", 1) ->sort('id') ->execute(); @@ -649,12 +679,14 @@ public function testDelta() { // the first item is being targeted. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("id.0.value", [1, 3, 5], 'IN') ->sort('id') ->execute(); $this->assertResult(1, 3, 5); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("id.1.value", [1, 3, 5], 'IN') ->sort('id') ->execute(); @@ -664,12 +696,14 @@ public function testDelta() { // only if just the field value is targeted. $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("id.%delta.value", [1, 3, 5], 'IN') ->sort('id') ->execute(); $this->assertResult(1, 3, 5); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("id.%delta.value", [1, 3, 5], 'IN') ->condition("id.%delta", 0, '=') ->sort('id') @@ -677,6 +711,7 @@ public function testDelta() { $this->assertResult(1, 3, 5); $this->queryResults = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition("id.%delta.value", [1, 3, 5], 'IN') ->condition("id.%delta", 1, '=') ->sort('id') @@ -733,7 +768,7 @@ protected function assertBundleOrder($order) { * The tags and metadata should propagate to the SQL query object. */ public function testMetaData() { - $query = $this->storage->getQuery(); + $query = $this->storage->getQuery()->accessCheck(FALSE); $query ->addTag('efq_metadata_test') ->addMetaData('foo', 'bar') @@ -809,18 +844,21 @@ public function testCaseSensitivity() { // Check the case insensitive field, = operator. $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_ci', $fixtures[0]['lowercase'] . $fixtures[1]['lowercase']) ->execute(); $this->assertCount(1, $result, 'Case insensitive, lowercase'); $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_ci', $fixtures[0]['uppercase'] . $fixtures[1]['uppercase']) ->execute(); $this->assertCount(1, $result, 'Case insensitive, uppercase'); $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_ci', $fixtures[0]['uppercase'] . $fixtures[1]['lowercase']) ->execute(); $this->assertCount(1, $result, 'Case insensitive, mixed.'); @@ -828,18 +866,21 @@ public function testCaseSensitivity() { // Check the case sensitive field, = operator. $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_cs', $fixtures[0]['lowercase'] . $fixtures[1]['lowercase']) ->execute(); $this->assertCount(0, $result, 'Case sensitive, lowercase.'); $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_cs', $fixtures[0]['uppercase'] . $fixtures[1]['uppercase']) ->execute(); $this->assertCount(0, $result, 'Case sensitive, uppercase.'); $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_cs', $fixtures[0]['uppercase'] . $fixtures[1]['lowercase']) ->execute(); $this->assertCount(1, $result, 'Case sensitive, exact match.'); @@ -847,17 +888,20 @@ public function testCaseSensitivity() { // Check the case insensitive field, IN operator. $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_ci', [$fixtures[0]['lowercase'] . $fixtures[1]['lowercase']], 'IN') ->execute(); $this->assertCount(1, $result, 'Case insensitive, lowercase'); $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_ci', [$fixtures[0]['uppercase'] . $fixtures[1]['uppercase']], 'IN')->execute(); $this->assertCount(1, $result, 'Case insensitive, uppercase'); $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_ci', [$fixtures[0]['uppercase'] . $fixtures[1]['lowercase']], 'IN') ->execute(); $this->assertCount(1, $result, 'Case insensitive, mixed'); @@ -865,6 +909,7 @@ public function testCaseSensitivity() { // Check the case sensitive field, IN operator. $result = $this->storage ->getQuery() + ->accessCheck(FALSE) ->condition('field_cs', [$fixtures[0]['lowercase'] . $fixtures[1]['lowercase']], 'IN') ->execute(); $this->assertCount(0, $result, 'Case sensitive, lowercase'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php index 944883af3247f7a0ff67b760276a0df3d01441ef..f138296ec9565d383a2cbb64bc4ab25fc3931ddd 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php @@ -273,7 +273,7 @@ protected function doTestMultilingualProperties($entity_type) { // Test property conditions and orders with multiple languages in the same // query. - $query = \Drupal::entityQuery($entity_type); + $query = \Drupal::entityQuery($entity_type)->accessCheck(FALSE); $group = $query->andConditionGroup() ->condition('user_id', $properties[$default_langcode]['user_id'][0], '=', $default_langcode) ->condition('name', $properties[$default_langcode]['name'][0], '=', $default_langcode); @@ -289,7 +289,7 @@ protected function doTestMultilingualProperties($entity_type) { $field_value = $this->randomString(); $entity->getTranslation($langcode)->set($this->fieldName, [['value' => $field_value]]); $entity->save(); - $query = \Drupal::entityQuery($entity_type); + $query = \Drupal::entityQuery($entity_type)->accessCheck(FALSE); $default_langcode_group = $query->andConditionGroup() ->condition('user_id', $properties[$default_langcode]['user_id'][0], '=', $default_langcode) ->condition('name', $properties[$default_langcode]['name'][0], '=', $default_langcode); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php index a4c49794026c7a6add79f137f116a056c9a9a6d7..fe7cf34d4393123e7e00c8bad801176a620f20dd 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php @@ -295,7 +295,7 @@ protected function insertData($revisionable, $translatable) { // least three times. /** @var \Drupal\Core\Entity\TranslatableRevisionableStorageInterface|\Drupal\Core\Entity\EntityStorageInterface $storage */ $storage = $this->entityTypeManager->getStorage($this->entityTypeId); - $next_id = $storage->getQuery()->count()->execute() + 1; + $next_id = $storage->getQuery()->accessCheck(FALSE)->count()->execute() + 1; // Create test entities with two translations and two revisions. /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ diff --git a/core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php b/core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php index 24153b3ba2470b8ee0d629cf6ebdb1da33b2acab..08761c309a4aa6c376e59edd14ea3405c45347eb 100644 --- a/core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php +++ b/core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php @@ -48,7 +48,7 @@ protected function createPathAlias($path, $alias, $langcode = LanguageInterface: */ protected function loadPathAliasByConditions($conditions) { $storage = \Drupal::entityTypeManager()->getStorage('path_alias'); - $query = $storage->getQuery(); + $query = $storage->getQuery()->accessCheck(FALSE); foreach ($conditions as $field => $value) { $query->condition($field, $value); } @@ -70,7 +70,10 @@ protected function loadPathAliasByConditions($conditions) { * (optional) A message to display with the assertion. */ protected function assertPathAliasExists($alias, $langcode = NULL, $path = NULL, $message = NULL) { - $query = \Drupal::entityTypeManager()->getStorage('path_alias')->getQuery(); + $query = \Drupal::entityTypeManager() + ->getStorage('path_alias') + ->getQuery() + ->accessCheck(FALSE); $query->condition('alias', $alias, '='); if ($langcode) { $query->condition('langcode', $langcode, '='); @@ -96,7 +99,10 @@ protected function assertPathAliasExists($alias, $langcode = NULL, $path = NULL, * (optional) A message to display with the assertion. */ protected function assertPathAliasNotExists($alias, $langcode = NULL, $path = NULL, $message = NULL) { - $query = \Drupal::entityTypeManager()->getStorage('path_alias')->getQuery(); + $query = \Drupal::entityTypeManager() + ->getStorage('path_alias') + ->getQuery() + ->accessCheck(FALSE); $query->condition('alias', $alias, '='); if ($langcode) { $query->condition('langcode', $langcode, '=');