Access policy does not respect 'Disable SQL rewriting' option in views

Created on 21 August 2025, 5 months ago

Problem/Motivation

The Access policy module does not respect the Disable SQL rewriting option in Views.
Even when SQL rewriting is disabled, the module still adds access tags to the query.

Steps to reproduce

  • Create a View that lists content limited by an access policy.
  • Enable the Disable SQL rewriting option in the query settings.
  • Observe that the query is still altered by the access policy module.

Proposed resolution

Update access_policy_views_query_alter() to check the Disable SQL rewriting option before adding access tags.

Suggested fix:

  
    function access_policy_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
      if ($query instanceof Sql && empty($query->options['disable_sql_rewrite'])) {
        // Existing logic remains unchanged.
      }
    }
  

Remaining tasks

  • ➖ Apply patch.
  • ➖ Add test coverage for Views with SQL rewriting disabled.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024