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?

Files: 
CommentFileSizeAuthor
#8 hook_requirements_documentation-1933954-8.patch829 bytestoastieAlex
PASSED: [[SimpleTest]]: [MySQL] 53,359 pass(es).
[ View ]
#6 hook_requirments_documentation-1933954-6.patch960 bytestoastieAlex
PASSED: [[SimpleTest]]: [MySQL] 53,076 pass(es).
[ View ]
#2 hook_requirements_description-1933954-2.patch731 bytestoastieAlex
PASSED: [[SimpleTest]]: [MySQL] 53,069 pass(es).
[ View ]

Comments

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!

Status:Active» Needs review
StatusFileSize
new731 bytes
PASSED: [[SimpleTest]]: [MySQL] 53,069 pass(es).
[ View ]

I believe this reflects the intended key value for requirements.

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.

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.

> 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 :)

Status:Needs work» Needs review
StatusFileSize
new960 bytes
PASSED: [[SimpleTest]]: [MySQL] 53,076 pass(es).
[ View ]

Expanded description of the requirements array key.

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:

Status:Needs work» Needs review
StatusFileSize
new829 bytes
PASSED: [[SimpleTest]]: [MySQL] 53,359 pass(es).
[ View ]

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

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!

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"

Status:Reviewed & tested by the community» Needs work

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

Status:Needs work» Needs review
Issue tags:+Novice, +needs backport to D7

Status:Needs review» Reviewed & tested by the community

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.