Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By sun on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
Most entries returned by hook_requirements() no longer return an enforced severity for positive assertions.
- All neutral/informational requirements check results should not return a hard-coded severity level.
- Only return REQUIREMENT_INFO or REQUIREMENT_OK if you want to enforce the corresponding visual presentation.
This is because:
- The Drupal installer defaults to REQUIREMENT_OK for positive assertions, so the user who is installing Drupal gets the appropriate visual feedback for met requirements.
- The Status report page defaults to REQUIREMENT_INFO for all requirements checks. The visual feedback for positive assertions would turn the entire page "green" otherwise.
Drupal 7
function mymodule_requirements() {
$exists = (...);
$requirements['foo'] = array(
'title' => 'Foo extension',
'value' => $exists ? $t('Enabled') : $t('Missing'),
'severity' => !$exists ? REQUIREMENT_ERROR : REQUIREMENT_OK,
);
return $requirements;
}
Drupal 8
function mymodule_requirements() {
$exists = (...);
$requirements['foo'] = array(
'title' => 'Foo extension',
'value' => $exists ? $t('Enabled') : $('Missing'),
// Note: Depending on your code logic, you can also omit the 'severity' key entirely.
'severity' => !$exists ? REQUIREMENT_ERROR : NULL,
);
return $requirements;
}
Impacts:
Module developers