Problem/Motivation
After installing the GDPR Consent module and attempting to add a Consent field to a User entity, I encounter the following error:
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 core/lib/Drupal/Core/Entity/Query/Sql/Query.php).
This occurs when trying to complete the final step of the field addition process.
Proposed resolution
The solution is to add an explicit access check to the entity query in the UserConsentItem.php file. Here is the modified code:
$agreement_ids = \Drupal::entityQuery('gdpr_consent_agreement')
->condition('status', 1)
->accessCheck(TRUE)
->sort('title')
->execute();
$agreements = ConsentAgreement::loadMultiple($agreement_ids);
I've attached a patch with this change.
Steps to reproduce
Install the GDPR Consent module.
Try to add a Consent field to the User entity.
Follow the steps to add a field.
At the last step, the error appears.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | accessCheckFix.patch | 570 bytes | rbosscher |
Issue fork gdpr-3373447
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rbosscher commentedComment #3
keshavv commentedComment #4
silvi.addweb commentedWhen I added the Consent field, I ran into this problem.
.
After adding this patch it's working fine.
Comment #8
rajeshreeputraMerged!