Commit 08519bd2 authored by heddn's avatar heddn Committed by heddn
Browse files

Issue #3046857 by heddn, eiriksm: Add entry to site status page when PSAs are posted

parent 4196d19e
......@@ -12,3 +12,41 @@ function automatic_updates_uninstall() {
variable_del('automatic_updates_psa_endpoint');
variable_del('automatic_updates_enable_psa');
}
/**
* Implements hook_requirements().
*/
function automatic_updates_requirements($phase) {
if ($phase !== 'runtime') {
return;
}
$requirements = array();
_automatic_updates_psa_requirements($requirements);
return $requirements;
}
/**
* Display requirements from public service announcements.
*
* @param array $requirements
* The requirements array.
*/
function _automatic_updates_psa_requirements(array &$requirements) {
if (!variable_get('automatic_updates_enable_psa', TRUE)) {
return;
}
$requirements['automatic_updates_psa'] = [
'title' => t('<a href="@link">Drupal public service announcements</a>', ['@link' => 'https://www.drupal.org/docs/8/update/automatic-updates#psas']),
'severity' => REQUIREMENT_OK,
'value' => t('No announcements requiring attention.'),
];
$messages = AutomaticUpdatesPsa::getPublicServiceMessages();
if (!empty($messages)) {
$requirements['automatic_updates_psa']['severity'] = REQUIREMENT_ERROR;
$requirements['automatic_updates_psa']['value'] = format_plural(count($messages), '@count urgent announcement requires your attention:', '@count urgent announcements require your attention:');
$requirements['automatic_updates_psa']['description'] = theme('item_list', array(
'items' => $messages,
));
}
}
......@@ -26,8 +26,13 @@ function automatic_updates_init() {
if (in_array($_GET['q'], $disabled_routes)) {
return;
}
foreach (AutomaticUpdatesPsa::getPublicServiceMessages() as $psa) {
drupal_set_message($psa, 'error');
$messages = AutomaticUpdatesPsa::getPublicServiceMessages();
if ($messages) {
drupal_set_message(t('Drupal public service announcements:'), 'error');
foreach ($messages as $message) {
drupal_set_message($message, 'error');
}
}
}
}
......
......@@ -56,6 +56,10 @@ class AutomaticUpdatesTestCase extends DrupalWebTestCase {
$this->assertNoText('Drupal Core PSA: Critical Release - PSA-2019-02-19');
variable_set('automatic_updates_enable_psa', TRUE);
// Test site status report.
$this->drupalGet($this->getAbsoluteUrl('admin/reports/status'));
$this->assertText('3 urgent announcements require your attention:');
// Test cache.
$psa_endpoint = $this->getAbsoluteUrl('automatic_updates/test-json-denied');
variable_set('automatic_updates_psa_endpoint', $psa_endpoint);
......
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