API page: http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct...

Return value

A keyed array of requirements. Each requirement is itself an array with the following items:

A keyed array, but keyed by what?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Issue tags: +Novice, +Needs backport to D7

I looked through all the invocations of this hook, and it looks like the array keys are arbitrary but must be unique across modules. This should be added to the documentation of the return value. Thanks for reporting this!

toastieAlex’s picture

Status: Active » Needs review
FileSize
731 bytes

I believe this reflects the intended key value for requirements.

joachim’s picture

Status: Needs review » Needs work

Thanks for working on this!

+++ b/core/modules/system/system.api.php
@@ -2353,8 +2353,8 @@ function hook_file_url_alter(&$uri) {
+ *   A keyed array of requirements keyed by module_name. Each requirement is

That's not quite it, I'm afraid, as you might need to return more than one requirement in your module. Though it's certainly a good idea to prefix the key with the module name, to ensure uniqueness.

toastieAlex’s picture

Assigned: Unassigned » toastieAlex

@joachim, I agree that it's not quite it, but the more I read the code that processes requirements the more it looks like it just doesn't matter what the key is. As near as I can tell it's there to separate the requirements from one another, but otherwise install_verify_requirements and update_verify_requirements do not use the key.

I will post a new patch within 24 hours of the first one.

joachim’s picture

> it just doesn't matter what the key is. As near as I can tell it's there to separate the requirements from one another,

Yes, that's absolutely right! The key does not matter, but it has to be unique. Therefore, the best strategy is to prefix with MODULE_NAME and then add something descriptive, eg, mymodule_javascriptenabled, to make up a rubbish example :)

toastieAlex’s picture

Status: Needs work » Needs review
FileSize
960 bytes

Expanded description of the requirements array key.

jhodgdon’s picture

Status: Needs review » Needs work

We normally say "associative array" rather than "keyed array" in documentation, and refer to the array values as "values"... and I think this wording can be made a lot more concise and clear, and maybe we don't need to be quite so prescriptive about how to compose the names... how about something like:

An associative array where the keys are arbitrary but must be unique (it is suggested to use the module short name as a prefix) and the values are themselves associative arrays with the following elements:

toastieAlex’s picture

Status: Needs work » Needs review
FileSize
829 bytes

@jhodgdon, works for me, although as an old perl hacker I'd normally say hash instead of associative array.

jhodgdon’s picture

Assigned: toastieAlex » jhodgdon
Status: Needs review » Reviewed & tested by the community

Yeah, well PHP isn't Perl (which has a different data type for hashes and arrays). :) I'll get this committed when I can. Thanks!

jhodgdon’s picture

I'm going to wait on committing this until this "avoid commit conflicts" issue that touches system.api.php too is finished:
#1380720: Rename entity "bundle" to "subtype" in the UI text and help

xjm’s picture

Status: Reviewed & tested by the community » Needs work

The last submitted patch, hook_requirements_documentation-1933954-8.patch, failed testing.

xjm’s picture

Status: Needs work » Needs review
Issue tags: +Novice, +Needs backport to D7
xjm’s picture

Status: Needs review » Reviewed & tested by the community
jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks! Committed to 8.x and 7.x.

Automatically closed -- issue fixed for 2 weeks with no activity.