hook_requirements() messages currently work with render arrays for runtime requirements messages. However, the documentation does not explicitly state that render arrays are allowed. Additionally, install phase requirements do not support render arrays because in
drupal_check_module()they are passed to
drupal_set_message(), and also to a placeholder in a
t() following .
It should be a best practice to use render arrays for building markup together with translated strings, especially for admin use, because we've done a lot of work so that #markup minimizes overhead and side effects while ensuring safe output. The only case where we should avoid it is when we explicitly want something to be escaped rather than filtered.
Explicitly support render arrays in hook_requirements().
File followup for the expected behavior of 'value' and 'title'.Done: Add markup to the render arrays to ensure they're not escaped unexpectedly.Done Add a test for XSS.Not done; way too contrived in a
Test profiles and themes too.Not supported for the install phase and/or broken. See .
- (done in #62) Manually test a requirements error on module install.
- (done in #75) Manually test a requirements error on module update.
- (done in #86)
Add a test to ensure that description has a lower weight and comes first
- needs a test making sure markup arrays work in the installer and the updater See #89 - #96
- Followup to ensure Drush compatibility: https://github.com/drush-ops/drush/issues/1314
User interface changes
before for install
cannot use a render array for the description
after for install
can use a render array for the description
before for update
after for update
with the patch they are exactly the same (and the markup is the same)
Steps to manually test
To test it - it's a bit of a hack, but I altered the aggregator module so that it reported that curl was not installed even though it was. This is in 2505499-52-testing-do-not-test.patch.
- Ensure you have curl installed
- Apply 2505499-52-testing-do-not-test.patch (or the one in comment #62
- Enable the aggregator module
- You should see the message "The Aggregator module could not be installed because the PHP cURL library is not available. (Currently using cURL version Enabled)" even though cURL is actually installed.
steps to manually test update descriptions
- install drupal, log in as admin
- enable the aggregator module (with no changes)
- apply patch like in #75 (can toggle commenting and uncommenting either the string or the render array)
- go to /drupal/update.php