Subscribe to KernelEvents::REQUEST instead of KernelEvents::RESPONSE

Created on 10 November 2020, about 4 years ago
Updated 26 April 2023, over 1 year ago

Problem/Motivation

The module currently relies on KernelEvents::RESPONSE to allow/deny access to a page. This event fires very late in the request handling and allows other code to be executed.

Additionally, instead of directly sending the redirect response we should set this to the event in $event->setResponse.

Our setup/usecase is the following:

  1. We have a protected page/node with a private file referenced on it
  2. Access to the private file is being calculated in the hook_access()
  3. Since this hook runs before the event subscriber implemented in the protected pages module, we end up denying access to users even if they should have access.

Steps to reproduce

Adjust Drupal\protected_pages\EventSubscriber\ProtectedPagesSubscriber to rely on KernelEvents::REQUEST so we can return early and use $event->setResponse to set the response.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

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.

Production build 0.71.5 2024