Commit 68fb9577 authored by Marcus McDowell's avatar Marcus McDowell Committed by Sascha Grossenbacher
Browse files

Issue #3274484 by marcusml: Add explicit accessCheck(TRUE/FALSE) to content entity queries

parent d2713dff
Loading
Loading
Loading
Loading
+1 −0
Changes for sources/content/tests/src/Functional/ContentEntitySourceContentModerationTest.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -515,6 +515,7 @@ class ContentEntitySourceContentModerationTest extends TMGMTTestBase {
   */
  protected function assertNodeTranslationsRevisionsCount($id, $langcode, $expected) {
    $translation_revisions_count = \Drupal::entityQuery('node')
      ->accessCheck(FALSE)
      ->condition('nid', $id)
      ->condition('langcode', $langcode)
      ->allRevisions()
+1 −0
Changes for sources/content/tests/src/Kernel/ContentEntityUpdateParagraphTest.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ class ContentEntityUpdateParagraphTest extends ContentEntityTestBase {
    $id_field = \Drupal::entityTypeManager()->getDefinition($entity_type_id)->getKey('id');

    $revision_count = \Drupal::entityQuery($entity_type_id)
      ->accessCheck(FALSE)
      ->condition($id_field, $entity_id)
      ->allRevisions()
      ->count()
+1 −0
Changes for sources/tmgmt_config/src/ConfigSourcePluginUi.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -288,6 +288,7 @@ class ConfigSourcePluginUi extends SourcePluginUiBase {
    unset($property_conditions['target_language']);

    $search = \Drupal::entityQuery($entity_type_id);
    $search->accessCheck(TRUE);
    // unset($property_conditions['target_status']);

    foreach ($property_conditions as $property_name => $property_value) {
+2 −0
Changes for src/ContinuousManager.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ class ContinuousManager {
   */
  public function hasContinuousJobs() {
    $id = $this->entityTypeManager->getStorage('tmgmt_job')->getQuery()
      ->accessCheck(TRUE)
      ->condition('job_type', Job::TYPE_CONTINUOUS)
      ->range(0, 1)
      ->execute();
@@ -95,6 +96,7 @@ class ContinuousManager {
  public function getContinuousJobs($source_langcode) {
    $jobs = array();
    $ids = $this->entityTypeManager->getStorage('tmgmt_job')->getQuery()
      ->accessCheck(TRUE)
      ->condition('source_language', $source_langcode)
      ->condition('job_type', Job::TYPE_CONTINUOUS)
      ->condition('state', Job::STATE_CONTINUOUS)
+8 −0
Changes for src/Entity/Job.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -267,6 +267,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
    // Since we are deleting one or multiple jobs here we also need to delete
    // the attached job items and messages.
    $tjiids = \Drupal::entityQuery('tmgmt_job_item')
      ->accessCheck(TRUE)
      ->condition('tjid', array_keys($entities), 'IN')
      ->execute();
    if (!empty($tjiids)) {
@@ -275,6 +276,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
    }

    $mids = \Drupal::entityQuery('tmgmt_message')
      ->accessCheck(TRUE)
      ->condition('tjid', array_keys($entities), 'IN')
      ->execute();
    if (!empty($mids)) {
@@ -283,6 +285,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
    }

    $trids = \Drupal::entityQuery('tmgmt_remote')
      ->accessCheck(TRUE)
      ->condition('tjid', array_keys($entities), 'IN')
      ->execute();
    if (!empty($trids)) {
@@ -387,6 +390,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
  public function getItems($conditions = array()) {
    $items = [];
    $query = \Drupal::entityQuery('tmgmt_job_item')
      ->accessCheck(TRUE)
      ->condition('tjid', $this->id());
    foreach ($conditions as $key => $condition) {
      if (is_array($condition)) {
@@ -415,6 +419,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
   */
  public function getMostRecentItem($plugin, $item_type, $item_id) {
    $query = \Drupal::entityQuery('tmgmt_job_item')
      ->accessCheck(TRUE)
      ->condition('tjid', $this->id())
      ->condition('plugin', $plugin)
      ->condition('item_type', $item_type)
@@ -433,6 +438,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
   */
  public function getMessages($conditions = array()) {
    $query = \Drupal::entityQuery('tmgmt_message')
      ->accessCheck(TRUE)
      ->condition('tjid', $this->id());
    foreach ($conditions as $key => $condition) {
      if (is_array($condition)) {
@@ -901,6 +907,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
   */
  public function getRemoteMappings() {
    $trids = \Drupal::entityQuery('tmgmt_remote')
      ->accessCheck(TRUE)
      ->condition('tjid', $this->id())
      ->execute();

@@ -1040,6 +1047,7 @@ class Job extends ContentEntityBase implements EntityOwnerInterface, JobInterfac
      // Get existing job items that are have the same languages, same source,
      // are active or in review and are not the job item that we are checking.
      $existing_items = \Drupal::entityQuery('tmgmt_job_item')
        ->accessCheck(TRUE)
        ->condition('state', [JobItemInterface::STATE_ACTIVE, JobItemInterface::STATE_REVIEW], 'IN')
        ->condition('plugin', $item->getPlugin())
        ->condition('item_type', $item->getItemType())
Loading