Raven logger can corrupt module_implements_alter when instantiated before DrupalKernel has loaded module files

Created on 17 April 2023, about 2 years ago
Updated 7 May 2023, about 2 years ago

Problem/Motivation

Cross posting an issue I found recently that was triggered by a combination of using this module together with Middleware that depends on logging.

When Raven logger is constructed it is creating the a client which calls $moduleHandler->alter('raven_options')

As this is happening in the constructor there is no guarantee that the modules are loaded - as detailed in https://www.drupal.org/project/drupal/issues/3354753 πŸ› [11.x] Middleware that calls ModuleHandler->alter() can remove hooks from module_implements cache Closed: duplicate I believe this is causing a race condition that can corrupt the results of the module_implements cache.

Steps to reproduce

See https://www.drupal.org/project/drupal/issues/3354753 πŸ› [11.x] Middleware that calls ModuleHandler->alter() can remove hooks from module_implements cache Closed: duplicate

Proposed resolution

However if that is a valid / expected thing to be able to do (which I hope it its) and it falls on this module work before Drupal is fully bootstrapped I don't know if there is really any change in order that would resolve this issue. The only thing off the top of my head is moving from hooks to events to avoid the module system.

*Update*

Proposed resolution is to deprecate hooks and replace them with an Event.

Remaining tasks

  1. Update documentation in README.md
  2. Update deprecation notices in raven.api.php
  3. Add test coverage for new event

User interface changes

New configuration option "Disable deprecated alter hooks" which can be set to remove calls to ModuleHandler->alter

API changes

  1. Deprecate hook_raven_breadcrumb_alter, hook_raven_filter_alter, hook_raven_options_alter
  2. Introduce new Event type

Data model changes

n/a

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand ericgsmith

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

Comments & Activities

Production build 0.71.5 2024