Install-time REQUIREMENT_ERROR messages set by drupal_check_module() are rather weird, if $requirement['value'] is given. See for example a requirement supplied by simpletest_requirements():

The testing framework requires the sites/simpletest directory to exist and be writable in order to run tests.
(Currently using Simpletest site directory version Missing)

before

This is, because drupal_check_module() infers that $requirement['value'] contains the currently used version of a particular requirement, while it may also contain a current value or (as in this case) state:

Current workarounds:

In system_requirements(), at one point this problem was recognized and a workaround used, see:

      $requirements['file system']['value'] = t('Not writable');
[...]
      if ($phase == 'runtime') {
        $description = t('You may need to set the correct directory at the <a href=":admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', [':admin-file-system' => \Drupal::url('system.file_system_settings')]);
      }
      elseif ($phase == 'install') {
        // For the installer UI, we need different wording. 'value' will
        // be treated as version, so provide none there.
        $description = t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the <a href=":handbook_url">online handbook</a>.', [':handbook_url' => 'https://www.drupal.org/server-permissions']);
        $requirements['file system']['value'] = '';

Also, the newer Media module is working around this miswording, wrapping the current value in the $requirement['description'], so $requirement['value'] isn't set.

While this works, it is not how the hook_requirement() was meant to be used, and custom workarounds lead to code bloat, all instead of getting the basic problem fixed.

Solution:

While we could add another flag or revamp the whole system (which will happen one day but not now), hook_requirements() is used in some more places, so we don't want to mess with it. A simpler solution would be a more generic wording for this particular kind of use-cases:

        if (isset($requirement['value']) && $requirement['value']) {
-          $message = t('@requirements_message (Currently using @item version @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]);
+          $message = t('@requirements_message (Currently: @item = @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]);
        }

This is quite in line with what install_display_requirements() does:

        if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
          $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];
        }

and would yield perfectly acceptable messages like:

curl not found
directory missing
open basedir enabled
profile install hook

while also working fine with actual version numbers, such as another install requirement in system_requirements():

open basedir enabled

Comments

Pancho created an issue. See original summary.

pancho’s picture

Issue summary: View changes
pancho’s picture

Title: simpletest_requirements() sets weird error message » drupal_check_module() sets weirdly worded error messages
Issue summary: View changes
StatusFileSize
new8.77 KB
new5.76 KB
pancho’s picture

Status: Active » Needs work
StatusFileSize
new10.47 KB

First, preliminary approach at this. No big deal, but exact string checks might trigger a few test failures.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

kunalgautam’s picture

Assigned: Unassigned » kunalgautam
kunalgautam’s picture

StatusFileSize
new7.87 KB

Patch for Drupal 9.1

kunalgautam’s picture

StatusFileSize
new8.26 KB
new1.61 KB
kunalgautam’s picture

Assigned: kunalgautam » Unassigned
Status: Needs work » Needs review

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new164 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.