[10] Use QueryInterface::accessCheck() with TRUE or FALSE to specify whether access should be checked

Created on 24 March 2023, over 1 year ago
Updated 28 March 2023, over 1 year ago

Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. Call \Drupal\Core\Entity\Query\QueryInterface::accessCheck() with TRUE or FALSE to specify whether access should be checked.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India ajeet_kumar gurugaon

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.

  • Assigned to ajeet_kumar
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India ajeet_kumar gurugaon

    Hi Team I have created D10 combability patch please review it.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States tr Cascadia

    Most of the patch is out of scope - only the first hunk is relevant. Please remove the excess changes. Also, please review the other issues in the queue if you want to help out with things like the guesser. See for example Improve image detection Needs work .

    The deprecation notice does not show up in the automated D10 tests, so that means the code is not being tested. Please add a test.

    Also please link the change record in the issue summary as documentation of what is being done here.

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States tr Cascadia

    Here's a simple test case. This should pass on D9 but fail on D10 due to the accessCheck issue.

  • 🇺🇸United States tr Cascadia

    Evidently need to enable the 'field' module for functional tests ...

  • Status changed to Postponed: needs info over 1 year ago
  • 🇺🇸United States tr Cascadia

    OK, where and how did you get that error message? Were you running the current -dev or a previous verision?

    The reason I ask is that the change record Access checking must be explicitly specified on content entity queries says that this is specifically for content entity queries and does not apply to configuration entities. But the only entity query in Mime Mail is a query of the field_config configuration entity, which shouldn't be affected.

    And as you can see from the tests in #6 which run this query code, there is NO error reported either in D9 or D10. Leaving accessCheck() off a content entity query should throw an exception. Likewise, drupal-check and other tools do not point this out as a problem.

  • 🇮🇳India ajeet_kumar gurugaon

    I run drupal-check query and found some issue with drupal-check. I have created this patch for fix drupal-check issues.

    • TR committed bb74613d on 8.x-1.x
      Issue #3350070 by TR: Add test coverage for AdminForm
      
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • 🇺🇸United States tr Cascadia

    I'm going to commit my test because it demonstrates that Mime Mail is using the entity query properly, and because this will give us some minimal coverage for the AdminForm.

    I don't see anything else in your patch that needs to be addressed.

    • TR committed 4eea75f2 on 8.x-1.x
      Revert "Issue #3350070 by TR: Add test coverage for AdminForm"
      
      This...
    • TR committed 2f63946a on 8.x-1.x
      Issue #3350070 by TR: Add test coverage for AdminForm
      
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024