Created on 12 April 2023, about 1 year ago
Updated 13 April 2023, about 1 year ago

Problem/Motivation

When running the operation, a php error is generated:

Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in Drupal\Core\Entity\Query\Sql\Query->prepare() (line 141 of /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php)

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇫🇮Finland joey-santiago

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

Comments & Activities

  • Issue created by @joey-santiago
  • @joey-santiago opened merge request.
  • 🇮🇳India omkar_yewale Mumbai

    Hi @joey-santiago,
    While reviewing the MR, I realized there were a few possible changes we can do.

    /user_delete_reassign/src/Form/UserDeleteReassignConfigForm.php

    $roles = user_role_names(TRUE);
    foreach ($roles as $id => $val) {
      $roles[$id] = Html::escape($val);
    }
    

    To

    use Drupal\user\Entity\Role;
    
    $roles = Role::loadMultiple();
    foreach ($roles as $id => $role) {
      if ($id !== 'anonymous') {
        $roles[$id] = Html::escape($role->label());
      }
    }
    
    /user_delete_reassign/user_delete_reassign.module
    $nodes = \Drupal::entityQuery('node')
        ->condition('uid', $account->id())
        ->execute();
    node_mass_update($nodes, ['uid' => $new_user->id()], NULL, TRUE);
    

    To

    use use Drupal\Core\Entity\EntityTypeManagerInterface;
    
    $nodeStorage = \Drupal::service('entity_type.manager')->getStorage('node');
    $nodes = $nodeStorage->getQuery()
        ->condition('uid', $account->id())
        ->execute();
    $nodeStorage->updateMultiple($nodes, ['uid' => $new_user->id()], NULL, TRUE);
    
Production build 0.69.0 2024