You are here

function _update_message_text in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/update/update.module \_update_message_text()
  2. 6 modules/update/update.module \_update_message_text()
  3. 7 modules/update/update.module \_update_message_text()
  4. 9 core/modules/update/update.module \_update_message_text()

Returns the appropriate message text when site is out of date or not secure.

These error messages are shared by both update_requirements() for the site-wide status report at admin/reports/status and in the body of the notification email messages generated by update_cron().

Parameters

$msg_type: String to indicate what kind of message to generate. Can be either 'core' or 'contrib'.

$msg_reason: Integer constant specifying why message is generated.

$langcode: (optional) A language code to use. Defaults to NULL.

Return value

The properly translated error message for the given key.

2 calls to _update_message_text()
update_mail in core/modules/update/update.module
Implements hook_mail().
_update_requirement_check in core/modules/update/update.install
Fills in the requirements array.

File

core/modules/update/update.module, line 435
Handles updates of Drupal core and contributed projects.

Code

function _update_message_text($msg_type, $msg_reason, $langcode = NULL) {
  $text = '';
  switch ($msg_reason) {
    case UpdateManagerInterface::NOT_SECURE:
      if ($msg_type == 'core') {
        $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', [], [
          'langcode' => $langcode,
        ]);
      }
      else {
        $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', [], [
          'langcode' => $langcode,
        ]);
      }
      break;
    case UpdateManagerInterface::REVOKED:
      if ($msg_type == 'core') {
        $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', [], [
          'langcode' => $langcode,
        ]);
      }
      else {
        $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', [], [
          'langcode' => $langcode,
        ]);
      }
      break;
    case UpdateManagerInterface::NOT_SUPPORTED:
      if ($msg_type == 'core') {
        $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', [], [
          'langcode' => $langcode,
        ]);
      }
      else {
        $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended. See the project homepage for more details.', [], [
          'langcode' => $langcode,
        ]);
      }
      break;
    case UpdateManagerInterface::NOT_CURRENT:
      if ($msg_type == 'core') {
        $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', [], [
          'langcode' => $langcode,
        ]);
      }
      else {
        $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', [], [
          'langcode' => $langcode,
        ]);
      }
      break;
    case UpdateFetcherInterface::UNKNOWN:
    case UpdateFetcherInterface::NOT_CHECKED:
    case UpdateFetcherInterface::NOT_FETCHED:
    case UpdateFetcherInterface::FETCH_PENDING:
      if ($msg_type == 'core') {
        $text = t('There was a problem checking <a href=":update-report">available updates</a> for Drupal.', [
          ':update-report' => Url::fromRoute('update.status')
            ->toString(),
        ], [
          'langcode' => $langcode,
        ]);
      }
      else {
        $text = t('There was a problem checking <a href=":update-report">available updates</a> for your modules or themes.', [
          ':update-report' => Url::fromRoute('update.status')
            ->toString(),
        ], [
          'langcode' => $langcode,
        ]);
      }
      break;
  }
  return $text;
}