Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Issue forks
automatic_updates-3242724
Commits
08519bd2
Commit
08519bd2
authored
Jun 05, 2019
by
heddn
Committed by
heddn
Jun 05, 2019
Browse files
Issue
#3046857
by heddn, eiriksm: Add entry to site status page when PSAs are posted
parent
4196d19e
Changes
3
Hide whitespace changes
Inline
Side-by-side
automatic_updates.install
View file @
08519bd2
...
...
@@ -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
,
));
}
}
automatic_updates.module
View file @
08519bd2
...
...
@@ -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'
);
}
}
}
}
...
...
tests/automatic_updates.test
View file @
08519bd2
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment