Hidden/removed items by this module still count for the views pager

Created on 13 June 2023, about 1 year ago
Updated 22 June 2023, about 1 year ago

Problem/Motivation

If you have a view with a pager showing 5 items per page,
And this module filters out (removes) 4 items on the first page for the current user,
then the first page only displays 1 item instead of 5

Steps to reproduce

- Create 6 or more entities of the same type
- Create a user that only has permission to view two of the entities based on a custom hook_entity_access based on for example some field values
- Create a view that shows all those entities with a pager. For example 5 items per page (if you are admin or have permission to view all the items in the view). Preferably make sure that the two items where the user has permission to are the first and the last item in the view.
- Check that the user for now can see all entities in the view.
- Enable this module, and set the view in /admin/config/system/views-entity-access-check
- You will see that the user no longer sees entities where he does not have permission to, which is great. But the view now only shows 1 item on the first page, and the second item that the user has access to on the second page, instead of showing both items on the first page.

πŸ› Bug report
Status

Active

Version

0.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium flyke

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

Comments & Activities

  • Issue created by @flyke
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks @flyke, sadly I have no idea how to fix this with the current Drupal access control system. If anyone has an idea, please provide a MR. I think this might not be solvable currently, but would be super happy to see a solution.

  • πŸ‡§πŸ‡ͺBelgium flyke

    Not sure. It will only work if the actual query is rewritten instead of just removing items from the views result.
    So you would need a custom src/Plugin/views/filter instead I think.
    But I have no idea how to create a general filter that would work on most views to alter the query to account for user access.

Production build 0.69.0 2024