Problem/Motivation

There are cases in which you may want to change the severity of a status page requirement (e.g., downgrade or upgrade) e.g. what we are doing at https://www.drupal.org/project/trusted_reverse_proxy to downgrade an error to info/checked.

Steps to reproduce

It's possible to adjust the variables for the status report page with hook_preprocess_HOOK(), e.g. hook_preprocess_status_report_page(), however this addresses the render array a little too late in the pipeline. StatusReportPage::preRenderCounters() will have already run, and so there is a certain amount of reproduction of code from this method into the preprocess function to maintain consistent presentation (e.g., when a category becomes empty and should be hidden or vice versa.)

Proposed resolution

Provide an event for modules to alter the requirements data prior to it being added to the render array.

Remaining tasks

Flesh out the approach and write code :-)

User interface changes

None

API changes

Should be backwards-compatible and existing render array-powered implementations should continue to work.

Data model changes

None

Release notes snippet

Not necessary?

Comments

bradjones1 created an issue. See original summary.

longwave’s picture

I know we are moving away from hooks to events, but it feels like adding hook_requirements_alter() would be the simplest solution here.

bradjones1’s picture

I'm curious why hooks are perceived as simpler than events? They are not particularly difficult to set up? Appreciate your insight.

longwave’s picture

In this case it's simply because hook_requirements() already exists and so the expected Drupalism here is to have hook_requirements_alter() if you want to make changes. I agree that events are almost as simple when designed from scratch, but I think mixing both hooks and events for the same data will add confusion.

longwave’s picture

I didn't search the issue queue until now, maybe we should revive #309040: Add hook_requirements_alter()?

bradjones1’s picture

Status: Active » Closed (duplicate)
Related issues: +#309040: Add hook_requirements_alter()

Marking as a duplicate of #309040: Add hook_requirements_alter()