improve update status email subject
5 unresolved threads
5 unresolved threads
Closes #1818764
Merge request reports
Activity
added 126 commits
-
9a719962...82d325ee - 125 commits from branch
project:11.x
- 7998ca80 - Update message and add tests
-
9a719962...82d325ee - 125 commits from branch
392 392 function update_mail($key, &$message, $params) { 393 393 $langcode = $message['langcode']; 394 394 $language = \Drupal::languageManager()->getLanguage($langcode); 395 $message['subject'] .= t('New release(s) available for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name')], ['langcode' => $langcode]); 395 396 // Set the message subject. 397 $subject = ''; 398 $all_reasons = array_unique(array_values($params)); 399 // If any reason is security then use the security subject. changed this line in version 4 of the diff
394 394 $language = \Drupal::languageManager()->getLanguage($langcode); 395 $message['subject'] .= t('New release(s) available for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name')], ['langcode' => $langcode]); 395 396 // Set the message subject. 397 $subject = ''; 398 $all_reasons = array_unique(array_values($params)); 399 // If any reason is security then use the security subject. 400 $security = array_filter($all_reasons, function ($item) { 401 return in_array($item, [UpdateManagerInterface::NOT_SECURE, UpdateManagerInterface::REVOKED]); 402 }); 403 if ($security) { 404 $subject = t('Security release(s) available for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name'), 'langcode' => $langcode]); 405 } 406 407 // If no subject yet then check for fetch failures. If all the reasons 408 // are fetch failures the use the fetch subject. - Comment on lines +407 to +408
changed this line in version 4 of the diff
404 $subject = t('Security release(s) available for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name'), 'langcode' => $langcode]); 405 } 406 407 // If no subject yet then check for fetch failures. If all the reasons 408 // are fetch failures the use the fetch subject. 409 if (empty($subject)) { 410 $fetch = array_filter($all_reasons, function ($item) { 411 return $item > 0; 412 }); 413 if (empty($fetch) && !empty($all_reasons)) { 414 $subject = t('Failed to get release information for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name'), 'langcode' => $langcode]); 415 } 416 } 417 418 // If still no subject, then there are non-security updates and use the non- 419 // security subject. Then update the subject in the existing message. - Comment on lines +418 to +419
418 // If still no subject, then there are non-security updates and use the non- 419 // security subject. Then update the subject in the existing message. 418 // If the subject still has not been set, then there are only non-security 419 // updates. Use the subject for non-security updates. changed this line in version 4 of the diff
408 // are fetch failures the use the fetch subject. 409 if (empty($subject)) { 410 $fetch = array_filter($all_reasons, function ($item) { 411 return $item > 0; 412 }); 413 if (empty($fetch) && !empty($all_reasons)) { 414 $subject = t('Failed to get release information for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name'), 'langcode' => $langcode]); 415 } 416 } 417 418 // If still no subject, then there are non-security updates and use the non- 419 // security subject. Then update the subject in the existing message. 420 if (empty($subject)) { 421 $subject = t('New release(s) available for @site_name', ['@site_name' => \Drupal::config('system.site')->get('name'), 'langcode' => $langcode]); 422 } 423 $message['subject'] .= $subject; 76 77 * 77 78 * @dataProvider providerTestUpdateEmail 78 79 */ 79 public function testUpdateEmail($notification_threshold, $params, $authorized, array $expected_body) { 80 public function testUpdateEmail($notification_threshold, $params, $authorized, $expected_subject, array $expected_body) { - Edited by Jess
changed this line in version 4 of the diff
added 1 commit
Please register or sign in to reply