Commit 8ba635b3 authored by alexpott's avatar alexpott

Issue #2501683 by sclapp, kgoel, xjm, YesCT, josephdpurcell, stefan.r, izus,...

Issue #2501683 by sclapp, kgoel, xjm, YesCT, josephdpurcell, stefan.r, izus, joelpittet: Remove SafeMarkup::set in _update_message_text()
parent 794cf89a
...@@ -107,8 +107,17 @@ function _update_requirement_check($project, $type) { ...@@ -107,8 +107,17 @@ function _update_requirement_check($project, $type) {
$status = $project['status']; $status = $project['status'];
if ($status != UPDATE_CURRENT) { if ($status != UPDATE_CURRENT) {
$requirement['reason'] = $status; $requirement['reason'] = $status;
$requirement['description'] = _update_message_text($type, $status, TRUE);
$requirement['severity'] = REQUIREMENT_ERROR; $requirement['severity'] = REQUIREMENT_ERROR;
// Append the available updates link to the message from
// _update_message_text(), and format the two translated strings together in
// a single paragraph.
$requirement['description'][] = ['#markup' => _update_message_text($type, $status)];
if (update_manager_access()) {
$requirement['description'][] = ['#prefix' => ' ', '#markup' => t('See the <a href="@available_updates">available updates</a> page for more information and to install your missing updates.', ['@available_updates' => \Drupal::url('update.report_update')])];
}
else {
$requirement['description'][] = ['#prefix' => ' ', '#markup' => t('See the <a href="@available_updates">available updates</a> page for more information.', ['@available_updates' => \Drupal::url('update.status')])];
}
} }
switch ($status) { switch ($status) {
case UPDATE_NOT_SECURE: case UPDATE_NOT_SECURE:
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* ability to install contributed modules and themes via an user interface. * ability to install contributed modules and themes via an user interface.
*/ */
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
...@@ -437,7 +436,7 @@ function update_mail($key, &$message, $params) { ...@@ -437,7 +436,7 @@ function update_mail($key, &$message, $params) {
$language = \Drupal::languageManager()->getLanguage($langcode); $language = \Drupal::languageManager()->getLanguage($langcode);
$message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => \Drupal::config('system.site')->get('name')), array('langcode' => $langcode)); $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => \Drupal::config('system.site')->get('name')), array('langcode' => $langcode));
foreach ($params as $msg_type => $msg_reason) { foreach ($params as $msg_type => $msg_reason) {
$message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $langcode); $message['body'][] = _update_message_text($msg_type, $msg_reason, $langcode);
} }
$message['body'][] = t('See the available updates page for more information:', array(), array('langcode' => $langcode)) . "\n" . \Drupal::url('update.status', [], ['absolute' => TRUE, 'language' => $language]); $message['body'][] = t('See the available updates page for more information:', array(), array('langcode' => $langcode)) . "\n" . \Drupal::url('update.status', [], ['absolute' => TRUE, 'language' => $language]);
if (update_manager_access()) { if (update_manager_access()) {
...@@ -464,16 +463,13 @@ function update_mail($key, &$message, $params) { ...@@ -464,16 +463,13 @@ function update_mail($key, &$message, $params) {
* or 'contrib'. * or 'contrib'.
* @param $msg_reason * @param $msg_reason
* Integer constant specifying why message is generated. * Integer constant specifying why message is generated.
* @param $report_link
* (optional) Boolean that controls if a link to the updates report should be
* added. Defaults to FALSE.
* @param $langcode * @param $langcode
* (optional) A language code to use. Defaults to NULL. * (optional) A language code to use. Defaults to NULL.
* *
* @return * @return
* The properly translated error message for the given key. * The properly translated error message for the given key.
*/ */
function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $langcode = NULL) { function _update_message_text($msg_type, $msg_reason, $langcode = NULL) {
$text = ''; $text = '';
switch ($msg_reason) { switch ($msg_reason) {
case UPDATE_NOT_SECURE: case UPDATE_NOT_SECURE:
...@@ -524,23 +520,8 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan ...@@ -524,23 +520,8 @@ function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $lan
} }
break; break;
} }
if (!empty($langcode)) {
$language = \Drupal::languageManager()->getLanguage($langcode);
}
else {
$language = NULL;
}
if ($report_link) {
if (update_manager_access()) {
$text .= ' ' . t('See the <a href="@available_updates">available updates</a> page for more information and to install your missing updates.', array('@available_updates' => \Drupal::url('update.report_update', [], ['language' => $language])), array('langcode' => $langcode));
}
else {
$text .= ' ' . t('See the <a href="@available_updates">available updates</a> page for more information.', array('@available_updates' => \Drupal::url('update.status', [], ['language' => $language])), array('langcode' => $langcode));
}
}
// All strings are t() and empty space concatenated so return SafeMarkup. return $text;
return SafeMarkup::set($text);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment