Implements early return on buildGrantsQueryCondition

Created on 27 May 2021, over 3 years ago
Updated 16 January 2023, over 1 year ago

Problem/Motivation

We're talking at https://www.drupal.org/project/drupal/issues/106721#comment-14115502 and on the file
core/modules/node/src/NodeGrantDatabaseStorage.php
there is a method buildGrantsQueryCondition that we can use early return to be easier to ready and avoid Hadouken effect

Proposed resolution

Change from:

protected function buildGrantsQueryCondition(array $node_access_grants) {
  $grants = $this->database->condition('OR');
  foreach ($node_access_grants as $realm => $gids) {
    if (!empty($gids)) {
      $and = $this->database->condition('AND');
      $grants->condition($and
        ->condition('gid', $gids, 'IN')
        ->condition('realm', $realm)
      );
    }
  }

  return $grants;
}

To:

protected function buildGrantsQueryCondition(array $node_access_grants) {
  $grants = $this->database->condition('OR');
  foreach ($node_access_grants as $realm => $gids) {

    if (empty($gids)) {
      continue;
    }

    $and = $this->database->condition('AND');
    $grants->condition($and
      ->condition('gid', $gids, 'IN')
      ->condition('realm', $realm)
    );
  }
  

  return $grants;
}
🐛 Bug report
Status

Closed: won't fix

Version

10.1

Component
Node system 

Last updated less than a minute ago

No maintainer
Created by

🇧🇷Brazil RenatoG Campinas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue was unassigned.
  • Status changed to RTBC over 1 year ago
  • Status changed to Closed: won't fix over 1 year ago
Production build 0.71.5 2024