vppr_access can be called excessively and loads all vocabularies multiple times

Created on 20 October 2023, 8 months ago

Problem/Motivation

vppr_access is called by implementations of hook_ENTITY_TYPE_access like vppr_taxonomy_term_access. This results in cases like if a form field uses a list of terms for options, on each term view, vppr_access runs which calls VpprPermissions::permissions() and loads all vocabularies, per term in the list. This is inefficient and wastes time reloading the vocabularies.

A couple of questions

  1. Should this module care about the view operation? vppr_access could check to see if the operation is view and return FALSE to return a neutral AccessResult and let other checks determine it.
  2. Should the list of permissions generated by the module be cached?

Steps to reproduce

  1. Render a list of taxonomy terms in some way, e.g. a view page of terms, a form select with terms as options, etc
  2. Load the list. With a debugger, set a breakpoint in VpprPermissions::permissions and see that per term view, it loads all vocabularies to generate the permissions list.

Proposed resolution

  1. If it makes sense, ignore the view operation in entity access
  2. Cache the generated permission list in a cache bin and reuse it. Ideally, statically cache the list so that it is only retrieved once per PHP request
  3. The admin bypass check for if the current user has the 'administer taxonomy' permission can also run before loading all permissions to avoid loading all vocabularies

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Vocabulary Permissions Per Role

Created by

πŸ‡ΊπŸ‡ΈUnited States angrytoast Princeton, NJ

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

Comments & Activities

Production build 0.69.0 2024