Problem/Motivation

The status report general information should show system information but instead shows module runtime requirements, which can be misleading for PHP version if a module defines a minimum requirement.

In core/modules/system/system.routing.yml:

system.status:
 path: '/admin/reports/status'
 defaults:
   _controller: '\Drupal\system\Controller\SystemInfoController::status'
   _title: 'Status report'
 requirements:
   _permission: 'administer site configuration'

status() in core/modules/system/src/Controller/SystemInfoController.php:

 /**
  * Displays the site status report.
  *
  * @return array
  *   A render array containing a list of system requirements for the Drupal
  *   installation and whether this installation meets the requirements.
  */
 public function status() {
   $requirements = $this->systemManager->listRequirements();
   return ['#type' => 'status_report_page', '#requirements' => $requirements];
 }

listRequirements() in core/modules/system/src/SystemManager.php:

 /**
  * Displays the site status report. Can also be used as a pure check.
  *
  * @return array
  *   An array of system requirements.
  */
 public function listRequirements() {
   // Load .install files
   include_once DRUPAL_ROOT . '/core/includes/install.inc';
   drupal_load_updates();

   // Check run-time requirements and status information.
   $requirements = $this->moduleHandler->invokeAll('requirements', ['runtime']);
   uasort($requirements, function ($a, $b) {
     if (!isset($a['weight'])) {
       if (!isset($b['weight'])) {
         return strcasecmp($a['title'], $b['title']);
       }
       return -$b['weight'];
     }
     return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
   });

   return $requirements;
 }

If a given module requires a specific version of PHP, such as in https://www.drupal.org/project/trailing_slash/issues/3016988, then the status report will show 7.1 even if 7.2+ is actively running.

In trailing_slash/trailing_slash.install:

/**
* Implements hook_requirements().
*/
function trailing_slash_requirements($phase) {
 $requirements = [];
 $requirements['php'] = [
   'title' => t('PHP'),
   'value' => TRAILING_SLASH_MINIMUM_PHP,
 ];

 if (version_compare(phpversion(), TRAILING_SLASH_MINIMUM_PHP) < 0) {
   $requirements['php']['description'] = t('Your PHP installation is too old. This module requires at least PHP %version.', [
     '%version' => TRAILING_SLASH_MINIMUM_PHP,
   ]);
   $requirements['php']['severity'] = REQUIREMENT_ERROR;
 }
 return $requirements;
}

In trailing_slash/trailing_slash.module:

<?php

use Drupal\Core\Routing\RouteMatchInterface;

define('TRAILING_SLASH_MINIMUM_PHP', '7.1');

In trailing_slash/trailing_slash.info.yml:

name: Trailing Slash
description: Adds trailing slashes to Drupal URLs.
type: module
# core: 8.x
dependencies:
  - drupal:language
php: 7.1

# Information added by Drupal.org packaging script on 2018-09-07
version: '8.x-1.0'
core: '8.x'
project: 'trailing_slash'
datestamp: 1536320883

Proposed resolution

Could this check be switched to pull information from another source, perhaps from the phpinfo() function as output in /admin/reports/status/php?

Remaining tasks

  • Determine if this behavior is intended/preferred
  • Adjust the source of the PHP version check
  • Write tests

Comments

dan612 created an issue. See original summary.

dan612’s picture

Issue summary: View changes
cilefen’s picture

It may be the solution could be via Composer. I'll connect this issue.

Version: 8.7.6 » 8.7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

chippyjacob’s picture

Hi @dan612,

Any update on this issue?

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mstrelan’s picture

Status: Active » Closed (works as designed)

I think the issue is that the trailing slash module is overriding the core requirements. The $requirements['php'] value set by system.module sets the requirement for Drupal core. The trailing slash module should define its own requirement, or should change the description to mention that it's required for that particular module.