Problem/Motivation
As of Drupal ^10 an exception is thrown on the page if an entityQuery is being used without defining the accessCheck. See https://www.drupal.org/node/3201242.
Steps to reproduce
Attempt to save an entity using the video field with entering a value inside the video field. The following error will be visible on the page.
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).
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 397)
Drupal\video\Plugin\Field\FieldWidget\VideoEmbedWidget->extractFormValues() (Line: 237)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues() (Line: 1278)Proposed resolution
Add the accessCheck to the query.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3348748.patch | 3.55 KB | rishabjasrotia |
| #9 | 3348748_video_missing-entity-query-9.diff | 1.32 KB | codebymikey |
Issue fork video-3348748
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 #3
hershey.k commentedComment #4
hershey.k commentedComment #5
eric_a commentedYes, the widget is just broken right now. (Unless you're on Drupal 9, because the deprecated code still works on previous Drupal.)
But if one states that the module works on the current Drupal release, then it's pretty critical that it works on the current Drupal release.
The fix is simple. And passing nothing will just keep the old access check behavior. But without the fatal error.
Comment #7
lisotton commentedThere was one more place reported by Upgrade Status where the `accessCheck` was not called.
Comment #9
codebymikey commentedHi @lisotton,
Do you have the specific code where this is occurring?
accessCheck(FALSE)makes more sense to avoid attempting to create duplicate file entities with the sameuri.Comment #10
rishabjasrotia commentedPatch
Comment #11
lokarkristina commentedPatch #10 applies and solves the issue.
Tested on Drupal 10.1.4
Comment #14
podaroktnx