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.

Issue fork video-3348748

Command icon 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

hershey.k created an issue. See original summary.

hershey.k’s picture

Status: Active » Needs review
hershey.k’s picture

Assigned: hershey.k » Unassigned
eric_a’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Yes, 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.

lisotton made their first commit to this issue’s fork.

lisotton’s picture

Status: Reviewed & tested by the community » Needs review

There was one more place reported by Upgrade Status where the `accessCheck` was not called.

codebymikey made their first commit to this issue’s fork.

codebymikey’s picture

StatusFileSize
new1.32 KB

Hi @lisotton,

There was one more place reported by Upgrade Status where the `accessCheck` was not called.

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 same uri.

rishabjasrotia’s picture

StatusFileSize
new3.55 KB

Patch

lokarkristina’s picture

Patch #10 applies and solves the issue.

Tested on Drupal 10.1.4

podarok made their first commit to this issue’s fork.

podarok’s picture

Version: 3.0.x-dev » 3.0.5
Status: Needs review » Fixed

tnx

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.