Problem/Motivation

I have a need to suppress certain warnings on hosts where I can't control the php.ini. https://www.drupal.org/project/nagios/issues/2900271 and https://www.drupal.org/project/nagios/issues/3295094 are examples of other users needing to suppress warnings but I think there should be a generalized solution.

Since `hook_requirements_alter` already exists, this patch adds support for calling that hook when checking requirements.

Steps to reproduce

Create a module that uses `hook_requirements_alter`. When viewing the GUI status report, the hook will be respected. When calling the nagios module, it isn't.

Issue fork nagios-3558586

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

megaphonejon created an issue. See original summary.

tunic’s picture

Status: Active » Needs review

As I understand the idea is to mimic core behaviour, so after collecting all requirements give the change to alter them (in this case probably to remove them), right?

This sounds like the way to go. I would like to think about it just in case there is some edge case that I'm not aware of. Like, for current installations this may break any current workflow or way to use the module? I can't think on any. to be honest.

Also, @gogowitsch, if you read this, what do you think?

gogowitsch’s picture

Thanks for the issue and the PR, megaphonejon!

The motivation is clear and the code change looks fine. Within the next 10 days, I’ll build a local test setup just to get a better feeling.

I am hopeful nothing blocking will show up and I can merge this then.

gogowitsch’s picture

Status: Needs review » Fixed

I manually tested the proposed change. All looked good. I invented a requirement 'funky' to then silence it using this code:

function your_module_requirements_alter(array &$requirements) {
  # for debugging: print all keys: print_r(array_keys($requirements));
  if (isset($requirements['funky'])) {
    unset($requirements['funky']);
  }
}

Thanks again, megaphonejon!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.