Problem/Motivation

hook_requirements_alter() has been introduced recently (#309040: Add hook_requirements_alter()). It's called when the status report page is built, but it's not called when the update script looks for requirements, despite hook_requirements() being called.
This seems wrong to me. If it's on purpose, it should at least be documented.

Steps to reproduce

Untested as I discovered the problem in the code by accident while debugging something else. But I guess the way to test is to add a hook_requirements_alter() implementation in a custom module which triggers a requirement error. The update process (/update.php, or drush updb) should fail because of this hook implementation.

Proposed resolution

Call \Drupal::moduleHandler()->alter('requirements', $requirements); just after $requirements = \Drupal::moduleHandler()->invokeAll('requirements', ['update']);.

Remaining tasks

Agree this is a bug, make a patch or merge request, maybe with unit tests?

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

No need.

Issue fork drupal-3324995

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

GaëlG created an issue. See original summary.

dajjen made their first commit to this issue’s fork.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

claudiu.cristea made their first commit to this issue’s fork.

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
claudiu.cristea’s picture

Issue tags: -Needs tests

Added tests

gaëlg’s picture

Status: Needs review » Reviewed & tested by the community
alorenc’s picture

Thanks, I am able to alter requirements when the update script is performed.

quietone’s picture

I'm triaging RTBC issues. I read the IS, the comments and skimmed the patch. I didn't find any unanswered questions or other work to do.

Leaving at RTBC.

alexpott’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 64e5e002c2 to 11.x and 5e3b8c6d71 to 10.2.x. Thanks!

Backported to 10.2.x as a low risk bug fix.

  • alexpott committed 5e3b8c6d on 10.2.x
    Issue #3324995 by claudiu.cristea, GaëlG, dajjen:...

  • alexpott committed 64e5e002 on 11.x
    Issue #3324995 by claudiu.cristea, GaëlG, dajjen:...

Status: Fixed » Closed (fixed)

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